ZQuest Classic Coverage Report


Directory: src/
File: src/zc/guys.cpp
Date: 2025-09-03 02:14:11
Exec Total Coverage
Lines: 9215 12192 75.6%
Functions: 378 435 86.9%
Branches: 7306 12929 56.5%

Line Branch Exec Source
1 #include "base/handles.h"
2 #include "base/zdefs.h"
3 #include <cstring>
4 #include <optional>
5 #include <stdio.h>
6 #include "base/combo.h"
7 #include "base/general.h"
8 #include "base/zc_alleg.h"
9 #include "zc/guys.h"
10 #include "zc/replay.h"
11 #include "zc/zc_ffc.h"
12 #include "zc/zc_subscr.h"
13 #include "zc/zelda.h"
14 #include "base/zsys.h"
15 #include "base/msgstr.h"
16 #include "zc/maps.h"
17 #include "zc/hero.h"
18 #include "subscr.h"
19 #include "zc/ffscript.h"
20 #include "gamedata.h"
21 #include "defdata.h"
22 #include "zscriptversion.h"
23 #include "particles.h"
24 #include "base/zc_math.h"
25 #include "slopes.h"
26 #include "base/qrs.h"
27 #include "base/dmap.h"
28 #include "base/mapscr.h"
29 #include "base/misctypes.h"
30 #include "base/initdata.h"
31 #include "zc/combos.h"
32 #include "iter.h"
33
34 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
35
36 int32_t repaircharge=0;
37 bool adjustmagic=false;
38 bool learnslash=false;
39 int32_t wallm_load_clk=0;
40 int32_t sle_x,sle_y,sle_cnt,sle_clk=0;
41 int32_t vhead=0;
42
43 char *guy_string[eMAXGUYS];
44
45 void playLevelMusic();
46
47 #define IGNORE_SIDEVIEW_PLATFORMS (editorflags & ENEMY_FLAG14)
48 #define OFFGRID_ENEMY (editorflags & ENEMY_FLAG15)
49
50 1113385 void do_fix(zfix& coord, int32_t val, bool nearest_half = false)
51 {
52 1113385 int32_t c = coord.getInt();
53
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 1113108 times.
1113385 if(nearest_half)
54 {
55
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1113108 times.
1113108 if (c < 0)
56 c -= val / 2;
57 1113108 else c += (val/2);
58 1113108 }
59 1113385 c -= c % val;
60 1113385 coord = c;
61 1113385 }
62
63 38564049 static bool OUTOFBOUNDS(int32_t id, int32_t x, int32_t y)
64 {
65
4/4
✓ Branch 0 taken 38047443 times.
✓ Branch 1 taken 516606 times.
✓ Branch 2 taken 1215 times.
✓ Branch 3 taken 38562834 times.
38564049 if (y > world_h + (isSideViewGravity() && canfall(id) ? 16 : 176)) return true;
66
2/2
✓ Branch 0 taken 30320 times.
✓ Branch 1 taken 38532514 times.
38562834 if (y < -176) return true;
67
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38532514 times.
38532514 if (x < -256) return true;
68
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 38532448 times.
38532514 if (x > world_w+256) return true;
69 38532448 return false;
70 38564049 }
71
72 bool NEWOUTOFBOUNDS(int32_t x, int32_t y, int32_t z)
73 {
74 return
75 (
76 (y > FFCore.enemy_removal_point[spriteremovalY2])
77 || (y < FFCore.enemy_removal_point[spriteremovalY1])
78 || (x < FFCore.enemy_removal_point[spriteremovalX1])
79 || (x > FFCore.enemy_removal_point[spriteremovalX2])
80 || (z < FFCore.enemy_removal_point[spriteremovalZ1])
81 || (z > FFCore.enemy_removal_point[spriteremovalZ2])
82 );
83 }
84
85 6674 static void position_relative_to_screen(zfix& x, zfix& y, int32_t rx, int32_t ry)
86 {
87 6674 x = rx + (x.getInt()/256)*256;
88 6674 y = ry + (y.getInt()/176)*176;
89 6674 }
90
91 namespace
92 {
93 int32_t trapConstantHorizontalID;
94 int32_t trapConstantVerticalID;
95 int32_t trapLOSHorizontalID;
96 int32_t trapLOSVerticalID;
97 int32_t trapLOS4WayID;
98
99 int32_t cornerTrapID;
100 int32_t centerTrapID;
101
102 int32_t rockID;
103 int32_t zoraID;
104 int32_t statueID;
105 }
106
107 422 void identifyCFEnemies()
108 {
109 422 trapConstantHorizontalID=-1;
110 422 trapConstantVerticalID=-1;
111 422 trapLOSHorizontalID=-1;
112 422 trapLOSVerticalID=-1;
113 422 trapLOS4WayID=-1;
114 422 cornerTrapID=-1;
115 422 centerTrapID=-1;
116 422 rockID=-1;
117 422 zoraID=-1;
118 422 statueID=-1;
119
120
2/2
✓ Branch 0 taken 216064 times.
✓ Branch 1 taken 422 times.
216486 for(int32_t i=0; i<eMAXGUYS; i++)
121 {
122
3/4
✓ Branch 0 taken 417 times.
✓ Branch 1 taken 215647 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 417 times.
216064 if((guysbuf[i].flags&guy_trph) && trapLOSHorizontalID==-1)
123 417 trapLOSHorizontalID=i;
124
4/4
✓ Branch 0 taken 428 times.
✓ Branch 1 taken 215636 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 422 times.
216064 if((guysbuf[i].flags&guy_trpv) && trapLOSVerticalID==-1)
125 422 trapLOSVerticalID=i;
126
3/4
✓ Branch 0 taken 422 times.
✓ Branch 1 taken 215642 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 422 times.
216064 if((guysbuf[i].flags&guy_trp4) && trapLOS4WayID==-1)
127 422 trapLOS4WayID=i;
128
3/4
✓ Branch 0 taken 422 times.
✓ Branch 1 taken 215642 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 422 times.
216064 if((guysbuf[i].flags&guy_trplr) && trapConstantHorizontalID==-1)
129 422 trapConstantHorizontalID=i;
130
3/4
✓ Branch 0 taken 422 times.
✓ Branch 1 taken 215642 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 422 times.
216064 if((guysbuf[i].flags&guy_trpud) && trapConstantVerticalID==-1)
131 422 trapConstantVerticalID=i;
132
133
3/4
✓ Branch 0 taken 422 times.
✓ Branch 1 taken 215642 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 422 times.
216064 if((guysbuf[i].flags&guy_trap) && cornerTrapID==-1)
134 422 cornerTrapID=i;
135
3/4
✓ Branch 0 taken 422 times.
✓ Branch 1 taken 215642 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 422 times.
216064 if((guysbuf[i].flags&guy_trp2) && centerTrapID==-1)
136 422 centerTrapID=i;
137
138
3/4
✓ Branch 0 taken 422 times.
✓ Branch 1 taken 215642 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 422 times.
216064 if((guysbuf[i].flags&guy_rock) && rockID==-1)
139 422 rockID=i;
140
4/4
✓ Branch 0 taken 445 times.
✓ Branch 1 taken 215619 times.
✓ Branch 2 taken 26 times.
✓ Branch 3 taken 419 times.
216064 if((guysbuf[i].flags&guy_zora) && zoraID==-1)
141 419 zoraID=i;
142
143
4/4
✓ Branch 0 taken 485 times.
✓ Branch 1 taken 215579 times.
✓ Branch 2 taken 63 times.
✓ Branch 3 taken 422 times.
216064 if((guysbuf[i].flags & guy_fire) && statueID==-1)
144 422 statueID=i;
145 216064 }
146 422 }
147
148 32 int32_t random_layer_enemy(int screen)
149 {
150 32 int32_t cnt=count_layer_enemies(screen);
151 32 mapscr* base_scr = get_scr(screen);
152
153
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(cnt==0)
154 {
155 return eNONE;
156 }
157
158 32 int32_t ret=zc_oldrand()%cnt;
159 32 cnt=0;
160
161
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 for(int32_t i=0; i<6; ++i)
162 {
163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(base_scr->layermap[i]!=0)
164 {
165 32 const mapscr* layerscreen = get_canonical_scr(base_scr->layermap[i]-1, base_scr->layerscreen[i]);
166
167
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 for(int32_t j=0; j<10; ++j)
168 {
169
2/4
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 140 times.
140 if(layerscreen->enemy[j]>0&&layerscreen->enemy[j]<MAXGUYS)
170 {
171
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 108 times.
140 if(cnt==ret)
172 {
173 32 return layerscreen->enemy[j];
174 }
175
176 108 ++cnt;
177 108 }
178 108 }
179 }
180 }
181
182 return eNONE;
183 32 }
184
185 49 int32_t count_layer_enemies(int screen)
186 {
187 49 int32_t cnt=0;
188
189 49 mapscr* base_scr = get_scr(screen);
190
191
2/2
✓ Branch 0 taken 294 times.
✓ Branch 1 taken 49 times.
343 for(int32_t i=0; i<6; ++i)
192 {
193
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 79 times.
294 if (base_scr->layermap[i])
194 {
195 79 const mapscr* layerscreen = get_canonical_scr(base_scr->layermap[i]-1, base_scr->layerscreen[i]);
196
197
2/2
✓ Branch 0 taken 790 times.
✓ Branch 1 taken 79 times.
869 for(int32_t j=0; j<10; ++j)
198 {
199
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 420 times.
790 if(layerscreen->enemy[j]!=0)
200 {
201 420 ++cnt;
202 420 }
203 790 }
204 79 }
205 294 }
206
207 49 return cnt;
208 }
209
210 211789 int32_t hero_on_wall()
211 {
212 211789 zfix lx = Hero.getX();
213 211789 zfix ly = Hero.getY();
214
215
4/4
✓ Branch 0 taken 189837 times.
✓ Branch 1 taken 21952 times.
✓ Branch 2 taken 8850 times.
✓ Branch 3 taken 180987 times.
211789 if(lx>=48 && lx<=world_w-64)
216 {
217
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 180756 times.
180987 if(ly==32) return up+1;
218
219
2/2
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 180473 times.
180756 if(ly==world_h-48) return down+1;
220 180473 }
221
222
4/4
✓ Branch 0 taken 194033 times.
✓ Branch 1 taken 17242 times.
✓ Branch 2 taken 21403 times.
✓ Branch 3 taken 172630 times.
211275 if(ly>=48 && ly<=world_h-64)
223 {
224
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 172407 times.
172630 if(lx==32) return left+1;
225
226
2/2
✓ Branch 0 taken 172303 times.
✓ Branch 1 taken 104 times.
172407 if(lx==world_w-48) return right+1;
227 172303 }
228
229 210948 return 0;
230 211789 }
231
232 806969 bool tooclose(int32_t x,int32_t y,int32_t d)
233 {
234
2/2
✓ Branch 0 taken 600909 times.
✓ Branch 1 taken 206060 times.
806969 return (abs(int32_t(HeroX())-x)<d && abs(int32_t(HeroY())-y)<d);
235 }
236
237 4019514 bool enemy::overpit(enemy *e)
238 {
239 // This function (and shadow_overpit) has been broken since it was written, and only
240 // checked the same diagonal of the hitbox, over and over again. The bug is because both
241 // loops used the same variable name.
242 // Checking literally every pixel seems like overkill, so for now let's continue to
243 // do the single diagonal but just once. That's why the outer loop is commented out.
244
245 // for ( int32_t q = 0; q < hxsz; ++q )
246 {
247
2/2
✓ Branch 0 taken 37189774 times.
✓ Branch 1 taken 4000312 times.
41190086 for ( int32_t q = 0; q < hit_height; ++q )
248 {
249 //check every pixel of the hitbox
250
2/2
✓ Branch 0 taken 19202 times.
✓ Branch 1 taken 37170572 times.
37189774 if ( ispitfall(x+q+hxofs, y+q+hyofs) )
251 {
252 //if the hitbox is over a pit, we can't land
253 19202 return true;
254 }
255 37170572 }
256 }
257 4000312 return false;
258 4019514 }
259
260 12361841 bool enemy::shadow_overpit(enemy *e)
261 {
262 // for ( int32_t q = 0; q < hxsz; ++q )
263 {
264
2/2
✓ Branch 0 taken 177577154 times.
✓ Branch 1 taken 12335380 times.
189912534 for ( int32_t q = 0; q < hit_height; ++q )
265 {
266 //check every pixel of the hitbox
267
2/2
✓ Branch 0 taken 26461 times.
✓ Branch 1 taken 177550693 times.
177577154 if ( ispitfall(x+q+hxofs, y+q+hyofs+hit_height-2) )
268 {
269 //if the hitbox is over a pit, we can't land
270 26461 return true;
271 }
272 177550693 }
273 }
274 12335380 return false;
275 12361841 }
276
277 // Returns true iff a combo type or flag precludes enemy movement.
278 7438667 bool enemy::groundblocked(int32_t dx, int32_t dy, bool isKB)
279 {
280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7438667 times.
7438667 if(moveflags & move_ignore_blockflags) return false;
281 7438667 int32_t c = COMBOTYPE(dx,dy);
282
4/4
✓ Branch 0 taken 4895519 times.
✓ Branch 1 taken 2543148 times.
✓ Branch 2 taken 1400387 times.
✓ Branch 3 taken 1142761 times.
9981815 bool pit_blocks = (!(moveflags & (move_can_pitwalk|move_only_pitwalk)) && (!(moveflags & move_can_pitfall) || !isKB));
283
3/6
✓ Branch 0 taken 2524824 times.
✓ Branch 1 taken 4913843 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2524824 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7438667 bool water_blocks = (!(moveflags & (move_can_waterwalk|move_only_waterwalk|move_only_shallow_waterwalk)) && (!(moveflags & move_can_waterdrown) || !isKB) && get_qr(qr_DROWN));
284
5/6
✓ Branch 0 taken 2584370 times.
✓ Branch 1 taken 4854297 times.
✓ Branch 2 taken 2582493 times.
✓ Branch 3 taken 1877 times.
✓ Branch 4 taken 2582493 times.
✗ Branch 5 not taken.
14878098 return c==cPIT || c==cPITB || c==cPITC ||
285
4/6
✓ Branch 0 taken 2582493 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2582493 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2433745 times.
✓ Branch 5 taken 148748 times.
2582493 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
286 // Block enemies type and block enemies flags
287
2/2
✓ Branch 0 taken 2577217 times.
✓ Branch 1 taken 2428469 times.
148748 combo_class_buf[c].block_enemies&1 ||
288
4/4
✓ Branch 0 taken 2574547 times.
✓ Branch 1 taken 2670 times.
✓ Branch 2 taken 2574300 times.
✓ Branch 3 taken 247 times.
2577217 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
289
4/4
✓ Branch 0 taken 2573482 times.
✓ Branch 1 taken 818 times.
✓ Branch 2 taken 2573416 times.
✓ Branch 3 taken 66 times.
2574300 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
290 // Check for ladder-only combos which aren't dried water
291
4/4
✓ Branch 0 taken 10626 times.
✓ Branch 1 taken 2562790 times.
✓ Branch 2 taken 10331 times.
✓ Branch 3 taken 295 times.
5146537 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
292 // Check for drownable water
293
4/4
✓ Branch 0 taken 574658 times.
✓ Branch 1 taken 1998463 times.
✓ Branch 2 taken 2332 times.
✓ Branch 3 taken 572326 times.
2573121 (water_blocks && !(isSideViewGravity()) && (iswaterex_z3(MAPCOMBO(dx,dy), -1, dx, dy, false, false, true, false, false)));
294 2587011 }
295
296 // Returns true iff enemy is floating and blocked by a combo type or flag.
297 8696119 bool enemy::flyerblocked(int32_t dx, int32_t dy, int32_t special, bool isKB)
298 {
299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8696119 times.
8696119 if(moveflags & move_ignore_blockflags) return false;
300
4/4
✓ Branch 0 taken 6597137 times.
✓ Branch 1 taken 2098982 times.
✓ Branch 2 taken 1750204 times.
✓ Branch 3 taken 348778 times.
10795101 bool pit_blocks = (!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !isKB));
301
3/4
✓ Branch 0 taken 6611644 times.
✓ Branch 1 taken 2084475 times.
✓ Branch 2 taken 2084475 times.
✗ Branch 3 not taken.
10780594 bool water_blocks = (!(moveflags & move_can_waterwalk) && (!(moveflags & move_can_waterdrown) || !isKB));
302
2/2
✓ Branch 0 taken 1202011 times.
✓ Branch 1 taken 7494108 times.
16190227 return ((special==spw_floater)&&
303
2/2
✓ Branch 0 taken 7483965 times.
✓ Branch 1 taken 10143 times.
7494108 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
304
2/2
✓ Branch 0 taken 7483846 times.
✓ Branch 1 taken 119 times.
7483965 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
305
2/2
✓ Branch 0 taken 7483675 times.
✓ Branch 1 taken 171 times.
7483846 (MAPFLAG(dx,dy)==mfNOENEMY)||
306
2/2
✓ Branch 0 taken 7483420 times.
✓ Branch 1 taken 255 times.
7483675 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
307
4/4
✓ Branch 0 taken 1242529 times.
✓ Branch 1 taken 6240891 times.
✓ Branch 2 taken 4004 times.
✓ Branch 3 taken 1238525 times.
14962836 (water_blocks && iswaterex_z3(MAPCOMBO(dx, dy), -1, dx,dy, false, false, true)) ||
308
2/2
✓ Branch 0 taken 6231302 times.
✓ Branch 1 taken 1248114 times.
7479416 (pit_blocks && ispitfall(dx,dy))));
309 8696119 }
310 // Returns true iff a combo type or flag precludes enemy movement.
311 282052 bool groundblocked(int32_t dx, int32_t dy, guydata const& gd)
312 {
313 282052 int32_t c = COMBOTYPE(dx,dy);
314 282052 bool pit_blocks = !(gd.moveflags & move_can_pitwalk);
315
2/2
✓ Branch 0 taken 35554 times.
✓ Branch 1 taken 246498 times.
282052 bool water_blocks = !(gd.moveflags & move_can_waterwalk) && get_qr(qr_DROWN);
316
5/6
✓ Branch 0 taken 282032 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 281915 times.
✓ Branch 3 taken 117 times.
✓ Branch 4 taken 281915 times.
✗ Branch 5 not taken.
1062905 return c==cPIT || c==cPITB || c==cPITC ||
317
4/6
✓ Branch 0 taken 281915 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 281915 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 250042 times.
✓ Branch 5 taken 31873 times.
281915 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
318 // Block enemies type and block enemies flags
319
2/2
✓ Branch 0 taken 281342 times.
✓ Branch 1 taken 249469 times.
31873 combo_class_buf[c].block_enemies&1 ||
320
4/4
✓ Branch 0 taken 280955 times.
✓ Branch 1 taken 387 times.
✓ Branch 2 taken 280924 times.
✓ Branch 3 taken 31 times.
281342 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
321
4/4
✓ Branch 0 taken 277269 times.
✓ Branch 1 taken 3655 times.
✓ Branch 2 taken 276994 times.
✓ Branch 3 taken 275 times.
280924 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
322 // Check for ladder-only combos which aren't dried water
323
4/4
✓ Branch 0 taken 1044 times.
✓ Branch 1 taken 275950 times.
✓ Branch 2 taken 1005 times.
✓ Branch 3 taken 39 times.
553949 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
324 // Check for drownable water
325
4/4
✓ Branch 0 taken 53168 times.
✓ Branch 1 taken 223787 times.
✓ Branch 2 taken 28535 times.
✓ Branch 3 taken 24633 times.
276955 (water_blocks && !(isSideViewGravity()) && (iswaterex_z3(MAPCOMBO(dx,dy), -1, dx, dy, false, false, true)));
326 }
327
328 // Returns true iff enemy is floating and blocked by a combo type or flag.
329 139611 bool flyerblocked(int32_t dx, int32_t dy, int32_t special, guydata const& gd)
330 {
331
2/2
✓ Branch 0 taken 137288 times.
✓ Branch 1 taken 2323 times.
139611 bool pit_blocks = (!(gd.moveflags & move_can_pitwalk) && !(gd.moveflags & move_can_pitfall));
332 139611 bool water_blocks = !(gd.moveflags & move_can_waterwalk);
333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139611 times.
279222 return ((special==spw_floater)&&
334
2/2
✓ Branch 0 taken 139514 times.
✓ Branch 1 taken 97 times.
139611 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
335
2/2
✓ Branch 0 taken 139509 times.
✓ Branch 1 taken 5 times.
139514 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
336
2/2
✓ Branch 0 taken 139500 times.
✓ Branch 1 taken 9 times.
139509 (MAPFLAG(dx,dy)==mfNOENEMY)||
337
2/2
✓ Branch 0 taken 139471 times.
✓ Branch 1 taken 29 times.
139500 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
338
4/4
✓ Branch 0 taken 2321 times.
✓ Branch 1 taken 137150 times.
✓ Branch 2 taken 250 times.
✓ Branch 3 taken 2071 times.
278692 (water_blocks && iswaterex_z3(MAPCOMBO(dx,dy), -1, dx, dy, false, false, true)) ||
339
2/2
✓ Branch 0 taken 137150 times.
✓ Branch 1 taken 2071 times.
139221 (pit_blocks && ispitfall(dx,dy))));
340 }
341
342
5/10
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115240 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115240 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 115240 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 115240 times.
✗ Branch 9 not taken.
230480 enemy::enemy(zfix X,zfix Y,int32_t Id,int32_t Clk) : sprite()
343 115240 {
344
1/2
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
115240 x=X;
345
1/2
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
115240 y=Y;
346
3/6
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115240 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115240 times.
✗ Branch 5 not taken.
115240 screen_spawned=get_screen_for_world_xy(x.getInt(), y.getInt());
347 115240 id=Id;
348 115240 clk=Clk;
349
1/2
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
115240 floor_y=y;
350 115240 ceiling=false;
351 115240 fading = misc = clk2 = clk3 = stunclk = hclk = sclk = superman = 0;
352 115240 grumble = movestatus = posframe = timer = ox = oy = 0;
353
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 115240 times.
✓ Branch 2 taken 115240 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115240 times.
✗ Branch 5 not taken.
115240 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - ((isSideViewGravity()) ? 0 : 2);
354 115240 did_armos=true;
355 115240 script_spawned=false;
356
357 115240 d = guysbuf + (id & 0xFFF);
358 115240 hp = d->hp;
359 115240 starting_hp = hp;
360 // cs = d->cset;
361 //d variables
362
363 115240 flags=d->flags;
364 115240 flags=d->flags;
365 115240 s_tile=d->s_tile; //secondary (additional) tile(s)
366 115240 type=d->type;
367 115240 dcset=d->cset;
368 115240 cs=dcset;
369
2/2
✓ Branch 0 taken 89096 times.
✓ Branch 1 taken 26144 times.
115240 anim=get_qr(qr_NEWENEMYTILES)?d->e_anim:d->anim;
370 115240 dp=d->dp;
371 115240 wdp=d->wdp;
372 115240 wpn=d->weapon;
373 115240 wpnsprite = d-> wpnsprite; //2.6 -Z
374 115240 rate=d->rate;
375 115240 hrate=d->hrate;
376
1/2
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
115240 dstep=d->step;
377 115240 homing=d->homing;
378 115240 dmisc1=d->attributes[0];
379 115240 dmisc2=d->attributes[1];
380 115240 dmisc3=d->attributes[2];
381 115240 dmisc4=d->attributes[3];
382 115240 dmisc5=d->attributes[4];
383 115240 dmisc6=d->attributes[5];
384 115240 dmisc7=d->attributes[6];
385 115240 dmisc8=d->attributes[7];
386 115240 dmisc9=d->attributes[8];
387 115240 dmisc10=d->attributes[9];
388 115240 dmisc11=d->attributes[10];
389 115240 dmisc12=d->attributes[11];
390 115240 dmisc13=d->attributes[12];
391 115240 dmisc14=d->attributes[13];
392 115240 dmisc15=d->attributes[14];
393 115240 dmisc16=d->attributes[15];
394 115240 dmisc17=d->attributes[16];
395 115240 dmisc18=d->attributes[17];
396 115240 dmisc19=d->attributes[18];
397 115240 dmisc20=d->attributes[19];
398 115240 dmisc21=d->attributes[20];
399 115240 dmisc22=d->attributes[21];
400 115240 dmisc23=d->attributes[22];
401 115240 dmisc24=d->attributes[23];
402 115240 dmisc25=d->attributes[24];
403 115240 dmisc26=d->attributes[25];
404 115240 dmisc27=d->attributes[26];
405 115240 dmisc28=d->attributes[27];
406 115240 dmisc29=d->attributes[28];
407 115240 dmisc30=d->attributes[29];
408 115240 dmisc31=d->attributes[30];
409 115240 dmisc32=d->attributes[31];
410
2/2
✓ Branch 0 taken 4275 times.
✓ Branch 1 taken 110965 times.
115240 if (get_qr(qr_BROKEN_ATTRIBUTE_31_32))
411 {
412 110965 dmisc31 = dmisc32;
413 110965 dmisc32 = 0;
414 110965 }
415 115240 spr_shadow=d->spr_shadow;
416 115240 spr_death=d->spr_death;
417 115240 spr_spawn=d->spr_spawn;
418
419
2/2
✓ Branch 0 taken 4724840 times.
✓ Branch 1 taken 115240 times.
4840080 for(int32_t i=0; i<edefLAST255; i++)
420 4724840 defense[i]=d->defense[i];
421
422 115240 bgsfx=d->bgsfx;
423 115240 hitsfx=d->hitsfx;
424 115240 deadsfx=d->deadsfx;
425 115240 bosspal=d->bosspal;
426
427 115240 frozentile = d->frozentile;
428
429 115240 frozencset = d->frozencset;
430 115240 frozenclock = 0;
431
2/2
✓ Branch 0 taken 1152400 times.
✓ Branch 1 taken 115240 times.
1267640 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = d->frozenmisc[q];
432
433
2/2
✓ Branch 0 taken 1959080 times.
✓ Branch 1 taken 115240 times.
2074320 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = 0;
434 //firesfx = 0; //t.b.a -Z
435 115240 isCore = true; //t.b.a
436 115240 parentCore = 0; //t.b.a
437
438 115240 firesfx = d->firesfx;
439
2/2
✓ Branch 0 taken 3687680 times.
✓ Branch 1 taken 115240 times.
3802920 for ( int32_t q = 0; q < 32; q++ ) movement[q] = d->movement[q];
440
2/2
✓ Branch 0 taken 3687680 times.
✓ Branch 1 taken 115240 times.
3802920 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = d->new_weapon[q];
441
442 115240 script = d->script;
443
444
2/2
✓ Branch 0 taken 921920 times.
✓ Branch 1 taken 115240 times.
1037160 for ( int32_t q = 0; q < 8; q++ )
445 {
446 921920 initD[q] = d->initD[q];
447 921920 }
448
449 115240 stickclk = 0;
450 115240 submerged = false;
451 115240 didScriptThisFrame = false;
452 115240 activated_handle = std::nullopt;
453 115240 hitdir = -1;
454 115240 editorflags = d->editorflags; //set by Enemy Editor
455 //Set the drawing flag for this sprite.
456
1/2
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
115240 if ( (editorflags&ENEMY_FLAG12) ) { drawflags |= sprdrawflagALWAYSOLDDRAWS; }
457
458
459
2/2
✓ Branch 0 taken 8921 times.
✓ Branch 1 taken 106319 times.
115240 if(bosspal>-1)
460 {
461
1/2
✓ Branch 0 taken 8921 times.
✗ Branch 1 not taken.
8921 loadpalset(csBOSS,pSprite(bosspal));
462 8921 }
463
464
2/2
✓ Branch 0 taken 50331 times.
✓ Branch 1 taken 64909 times.
115240 if(bgsfx>-1)
465 {
466
1/2
✓ Branch 0 taken 50331 times.
✗ Branch 1 not taken.
50331 cont_sfx(bgsfx);
467 50331 }
468
469
2/2
✓ Branch 0 taken 89096 times.
✓ Branch 1 taken 26144 times.
115240 if(get_qr(qr_NEWENEMYTILES))
470 {
471 89096 o_tile=d->e_tile;
472 89096 frate = d->e_frate;
473 89096 }
474 else
475 {
476 26144 o_tile=d->tile;
477 26144 frate = d->frate;
478 }
479
480 115240 tile=0; //init to 0 here, but set it later.
481
482 115240 scripttile = -1;
483 115240 scriptflip = -1;
484 115240 do_animation = true;
485 115240 immortal = false;
486 115240 noSlide = false;
487 115240 deathexstate = -1;
488
489 115240 hashero=false;
490
491 // If they forgot the invisibility flag, here's another failsafe:
492
4/4
✓ Branch 0 taken 5793 times.
✓ Branch 1 taken 109447 times.
✓ Branch 2 taken 5699 times.
✓ Branch 3 taken 94 times.
115240 if(o_tile==0 && type!=eeSPINTILE)
493
1/2
✓ Branch 0 taken 5699 times.
✗ Branch 1 not taken.
5699 flags |= guy_invisible;
494
495 // step = d->step/100.0;
496 // To preserve the odd step values for Keese & Gleeok heads. -L
497
5/8
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115240 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12297 times.
✓ Branch 5 taken 102943 times.
✓ Branch 6 taken 12297 times.
✗ Branch 7 not taken.
115240 if(dstep==62.0) dstep+=0.5;
498
5/8
✓ Branch 0 taken 102943 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102943 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 699 times.
✓ Branch 5 taken 102244 times.
✓ Branch 6 taken 699 times.
✗ Branch 7 not taken.
102943 else if(dstep==89) dstep-=1/9;
499
500
5/10
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115240 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115240 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 115240 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 115240 times.
✗ Branch 9 not taken.
115240 step = zslongToFix(dstep*100);
501
502
503 115240 item_set = d->item_set;
504 115240 grumble = d->grumble;
505
506
2/2
✓ Branch 0 taken 90351 times.
✓ Branch 1 taken 24889 times.
115240 if(frate == 0)
507 24889 frate = 256;
508
509 115240 leader = itemguy = dying = scored = false;
510 115240 canfreeze = count_enemy = true;
511
1/2
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
115240 mainguy = !(flags & guy_doesnt_count);
512
1/2
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
115240 dir = zc_oldrand()&3;
513
514 //2.6 Enemy Editor Hit and TIle Sizes
515
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 115231 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
115240 if ( ((d->SIZEflags&OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
516 // al_trace("Enemy txsz:%i\n", txsz);
517
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 115231 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
115240 if ( ((d->SIZEflags&OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
518
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 115233 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
115240 if ( ((d->SIZEflags&OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
519
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 115233 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
115240 if ( ((d->SIZEflags&OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
520
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 115240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
115240 if ( ((d->SIZEflags&OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
521
1/2
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
115240 if ( (d->SIZEflags&OVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
522
1/2
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
115240 if ( (d->SIZEflags&OVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
523 // if ( (d->SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = d->hzofs;
524
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 115240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
115240 if ( (d->SIZEflags&OVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115240 times.
115240 if ( (d->SIZEflags&OVERRIDE_DRAW_Y_OFFSET) != 0 )
526 {
527 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
528 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
529 }
530
531
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 115240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
115240 if ( (d->SIZEflags&OVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
532
533 115240 SIZEflags = d->SIZEflags;
534
535
8/10
✓ Branch 0 taken 114991 times.
✓ Branch 1 taken 249 times.
✓ Branch 2 taken 366 times.
✓ Branch 3 taken 114874 times.
✓ Branch 4 taken 366 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 366 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 365 times.
115240 if((wpn==ewBomb || wpn==ewSBomb) && type!=eeOTHER && type!=eeFIRE && (type!=eeWALK || dmisc2 != e2tBOMBCHU))
536 1 wpn = 0;
537
538 //tile should never be 0 after init --Z (failsafe)
539
4/6
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115240 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 107998 times.
✓ Branch 5 taken 7242 times.
115240 if (tile <= 0 && FFCore.getQuestHeaderInfo(vZelda) >= 0x255) {tile = o_tile;}
540
541 //Moveflags; for gravity and pit interaction
542 115240 moveflags = d->moveflags;
543
3/4
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17706 times.
✓ Branch 3 taken 97534 times.
115240 if(!can_pitfall(false))
544 {
545 //Some enemies must not interact with pits. Force their flags, for sanity's sake.
546
2/4
✓ Branch 0 taken 17706 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17706 times.
✗ Branch 3 not taken.
17706 moveflags &= ~move_can_pitfall;
547
2/4
✓ Branch 0 taken 17706 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17706 times.
✗ Branch 3 not taken.
17706 moveflags &= ~move_can_waterdrown;
548 17706 }
549
550 115240 shieldCanBlock = get_qr(qr_GOHMA_UNDAMAGED_BUG)?true:false;
551
552 115240 specialsfx = d->specialsfx;
553
1/2
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
115240 weap_data = d->weap_data;
554 115240 }
555
556 114983 enemy::~enemy()
557 114983 {
558
1/2
✓ Branch 0 taken 114983 times.
✗ Branch 1 not taken.
114983 FFCore.destroySprite(this);
559
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 114970 times.
114983 if(hashero)
560 {
561
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 Hero.setEaten(0);
562 13 hashero=false;
563 13 }
564 114983 }
565
566 bool enemy::is_move_paused()
567 {
568 return (clk<0 || dying || stunclk || watch || ceiling || frozenclock || fallclk || drownclk);
569 }
570
571 7024 bool enemy::scr_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
572 {
573 7024 int32_t yg = (special==spw_floater)?8:0;
574 7024 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
575
576
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 if(input_x == -1000)
577 input_x = dx;
578
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 if(input_y == -1000)
579 input_y = dy;
580
581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7024 times.
14048 if(!(moveflags & move_ignore_screenedge)
582
4/6
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7024 times.
✓ Branch 4 taken 6707 times.
✓ Branch 5 taken 317 times.
7024 && ((input_x<(16-nb)) || (input_y<zc_max(16-yg-nb,0))
583
2/4
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
7024 || ((input_x+hit_width-1) >= (world_w-16+nb)) || ((input_y+hit_height-1) >= (world_h-16+nb))))
584 return true;
585
586
4/6
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 6934 times.
✓ Branch 2 taken 90 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
7024 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !kb)) //Don't walk into pits, unless being knocked back
587 {
588 if(ispitfall(dx,dy))
589 return true;
590 }
591
592 7024 bool flying = false;
593 7024 bool cansolid = false;
594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7024 times.
7024 if(moveflags & move_ignore_solidity)
595 cansolid = true;
596
2/4
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 6707 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7024 switch(special)
597 {
598 case spw_clipbottomright:
599 if(dy>=128 || dx>=208) return true;
600 break;
601 case spw_clipright:
602 break; //if(input_x>=208) return true; break;
603
604 case spw_wizzrobe: // fall through
605 case spw_floater: // Special case for fliers and wizzrobes - hack!
606 {
607
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 317 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
317 if(isdungeon(screen_spawned) && !(moveflags & move_ignore_screenedge))
608 {
609 if(dy < 32-yg || dy >= 144) return true;
610 if(dx < 32 || dx >= 224) return true;
611 }
612
2/4
✓ Branch 0 taken 317 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 317 times.
✗ Branch 3 not taken.
317 if(!(moveflags & move_ignore_blockflags) && flyerblocked(dx, dy, special, kb))
613 return true;
614 317 cansolid = true;
615 317 flying = true;
616 }
617 317 }
618
619 7024 dx = TRUNCATE_HALF_TILE(dx);
620 7024 dy = TRUNCATE_HALF_TILE(dy);
621
622
4/6
✓ Branch 0 taken 6707 times.
✓ Branch 1 taken 317 times.
✓ Branch 2 taken 6707 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6707 times.
✗ Branch 5 not taken.
7024 if(!flying && !(moveflags & move_ignore_blockflags) && groundblocked(dx,dy,kb)) return true;
623
624
4/8
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7024 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 7024 times.
7024 if (dx < 0 || dx >= world_w || dy < 0 || dy >= world_h)
625 return !(moveflags & move_ignore_screenedge);
626
627 // TODO: could this reuse _walkflag?
628
629 //_walkflag code
630 7024 mapscr* s0 = get_scr_for_world_xy_layer(dx, dy, 0);
631
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 mapscr* s1 = s0->layermap[0]-1 >= 0 ? get_scr_for_world_xy_layer(dx, dy, 1) : nullptr;
632
2/2
✓ Branch 0 taken 1038 times.
✓ Branch 1 taken 5986 times.
7024 mapscr* s2 = s0->layermap[1]-1 >= 0 ? get_scr_for_world_xy_layer(dx, dy, 2) : nullptr;
633
2/4
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
7024 if (!s1 || !s1->valid) s1 = s0;
634
3/4
✓ Branch 0 taken 1038 times.
✓ Branch 1 taken 5986 times.
✓ Branch 2 taken 1038 times.
✗ Branch 3 not taken.
7024 if (!s2 || !s2->valid) s2 = s0;
635
636 7024 int32_t cpos = COMBOPOS(dx%256, dy%176);
637
2/4
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
7024 int32_t ci = s0->data[cpos], ci1 = (s1?s1:s0)->data[cpos], ci2 = (s2?s2:s0)->data[cpos];
638 7024 newcombo c = combobuf[ci];
639
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 newcombo c1 = combobuf[ci1];
640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7024 times.
7024 newcombo c2 = combobuf[ci2];
641
642 7024 int32_t b=1;
643
2/2
✓ Branch 0 taken 3446 times.
✓ Branch 1 taken 3578 times.
7024 if(dx&8) b<<=2;
644
2/2
✓ Branch 0 taken 3374 times.
✓ Branch 1 taken 3650 times.
7024 if(dy&8) b<<=1;
645
646 #define iwtr(cmb, x, y, shallow) \
647 (shallow \
648 ? iswaterex_z3(cmb, -1, dx, dy, false, false, false, true, false) \
649 && !iswaterex_z3(cmb, -1, dx, dy, false, false, false, false, false) \
650 : iswaterex_z3(cmb, -1, dx, dy, false, false, false, false, false))
651
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool wtr = iwtr(ci, dx, dy, false);
652
4/6
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3473 times.
✓ Branch 3 taken 3551 times.
✓ Branch 4 taken 3473 times.
✗ Branch 5 not taken.
7024 bool shwtr = iwtr(ci, dx, dy, true);
653
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool pit = ispitfall(dx,dy);
654
655
5/8
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 6934 times.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 90 times.
✗ Branch 7 not taken.
7024 bool canwtr = (moveflags & move_can_waterwalk) || ((moveflags & move_can_waterdrown) && kb);
656
5/8
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 6934 times.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 90 times.
7024 bool canpit = (moveflags & move_can_pitwalk) || ((moveflags & move_can_pitfall) && kb);
657
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool needwtr = (moveflags & move_only_waterwalk);
658
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool needshwtr = (moveflags & move_only_shallow_waterwalk);
659
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool needpit = (moveflags & move_only_pitwalk);
660
661
2/2
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 6707 times.
7024 if(!cansolid)
662 {
663 6707 int32_t cwalkflag = c.walk & 0xF;
664
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6707 if (c.type == cBRIDGE && get_qr(qr_OLD_BRIDGE_COMBOS)) cwalkflag = 0;
665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (s1)
666 {
667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (c1.type == cBRIDGE)
668 {
669 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
670 {
671 int efflag = (c1.walk & 0xF0)>>4;
672 int newsolid = (c1.walk & 0xF);
673 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
674 }
675 else cwalkflag &= c1.walk;
676 }
677 6707 else cwalkflag |= c1.walk & 0xF;
678 6707 }
679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (s2)
680 {
681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (c2.type == cBRIDGE)
682 {
683 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
684 {
685 int efflag = (c2.walk & 0xF0)>>4;
686 int newsolid = (c2.walk & 0xF);
687 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
688 }
689 else cwalkflag &= c2.walk;
690 }
691 6707 else cwalkflag |= c2.walk & 0xF;
692 6707 }
693
2/2
✓ Branch 0 taken 239 times.
✓ Branch 1 taken 6468 times.
6707 if(cwalkflag & b)
694 239 return true;
695 6468 }
696
3/6
✓ Branch 0 taken 6785 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6785 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6785 times.
6785 if(needwtr || needshwtr || needpit)
697 {
698 bool ret = true;
699 if (needwtr && wtr) ret = false;
700 else if (needshwtr && shwtr) ret = false;
701 else if (needpit && pit) ret = false;
702 return ret;
703 }
704
3/4
✓ Branch 0 taken 3473 times.
✓ Branch 1 taken 3312 times.
✓ Branch 2 taken 3473 times.
✗ Branch 3 not taken.
6785 else if(wtr && !canwtr)
705 return true;
706
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6785 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6785 else if(pit && !canpit)
707 return true;
708
709 6785 return false;
710 7024 }
711
712 1535 bool enemy::scr_canmove(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv)
713 {
714
3/4
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 1111 times.
✓ Branch 2 taken 424 times.
✗ Branch 3 not taken.
1535 if(!(dx || dy)) return true;
715 1535 zfix bx = x+hxofs, by = y+hyofs; //left/top
716 1535 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
717
3/4
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 516 times.
✓ Branch 2 taken 1019 times.
✗ Branch 3 not taken.
1535 if(!ign_sv && dy < 0) //check gravity
718 {
719 if((moveflags & move_obeys_grav) && isSideViewGravity())
720 return false;
721 }
722
723
2/4
✓ Branch 0 taken 1535 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1535 times.
1535 bool nosolid = !((moveflags & move_ignore_solidity) || (special==spw_wizzrobe) || (special==spw_floater));
724
725
3/4
✓ Branch 0 taken 1111 times.
✓ Branch 1 taken 424 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1111 times.
1535 if(dx && !dy)
726 {
727
2/2
✓ Branch 0 taken 770 times.
✓ Branch 1 taken 341 times.
1111 if(dx < 0)
728 {
729
2/4
✓ Branch 0 taken 770 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 770 times.
770 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
730 770 int mx = (bx+dx).getFloor();
731
2/2
✓ Branch 0 taken 2976 times.
✓ Branch 1 taken 770 times.
3746 for(zfix ty = 0; by+ty < ry; ty += 8)
732 {
733
1/2
✓ Branch 0 taken 2976 times.
✗ Branch 1 not taken.
2976 if(scr_walkflag(mx, by+ty, special, left, mx, by, kb))
734 return false;
735 2976 }
736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 770 times.
770 if(scr_walkflag(mx, ry, special, left, mx, by, kb))
737 return false;
738
3/4
✓ Branch 0 taken 736 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 736 times.
✗ Branch 3 not taken.
770 if(nosolid && collide_object(bx+dx,by,-dx,hit_height,this))
739 return false;
740 770 }
741 else
742 {
743 341 int mx = (rx+dx).getCeil();
744 341 int lx = mx-hit_width+1;
745
2/2
✓ Branch 0 taken 2142 times.
✓ Branch 1 taken 340 times.
2482 for(zfix ty = 0; by+ty < ry; ty += 8)
746 {
747
2/2
✓ Branch 0 taken 2141 times.
✓ Branch 1 taken 1 times.
2142 if(scr_walkflag(mx, by+ty, special, right, lx, by, kb))
748 1 return false;
749 2141 }
750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 if(scr_walkflag(mx, ry, special, right, lx, by, kb))
751 return false;
752
2/4
✓ Branch 0 taken 340 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 340 times.
✗ Branch 3 not taken.
340 if(nosolid && collide_object(bx+hit_width,by,dx,hit_height,this))
753 return false;
754 }
755 1110 }
756
2/4
✓ Branch 0 taken 424 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 424 times.
424 else if(dy && !dx)
757 {
758
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 109 times.
424 if(dy < 0)
759 {
760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 315 times.
315 special = (special==spw_clipbottomright)?spw_none:special;
761 315 int my = (by+dy).getFloor();
762
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 77 times.
469 for(zfix tx = 0; bx+tx < rx; tx += 8)
763 {
764
2/2
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 238 times.
392 if(scr_walkflag(bx+tx, my, special, up, bx, my, kb))
765 238 return false;
766 154 }
767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(scr_walkflag(rx, my, special, up, bx, my, kb))
768 return false;
769
3/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
77 if(nosolid && collide_object(bx,by+dy,hit_width,-dy,this))
770 return false;
771 77 }
772 else
773 {
774 109 int my = (ry+dy).getCeil();
775 109 int ly = my-hit_height+1;
776
2/2
✓ Branch 0 taken 218 times.
✓ Branch 1 taken 109 times.
327 for(zfix tx = 0; bx+tx < rx; tx += 8)
777 {
778
1/2
✓ Branch 0 taken 218 times.
✗ Branch 1 not taken.
218 if(scr_walkflag(bx+tx, my, special, down, bx, ly, kb))
779 return false;
780 218 }
781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(scr_walkflag(rx, my, special, down, bx, ly, kb))
782 return false;
783
3/4
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 89 times.
109 if(nosolid && collide_object(bx,by+hit_height,hit_width,dy,this))
784 return false;
785 }
786 186 }
787 else //! Untested, and currently unused.
788 {
789 return scr_canmove(dx, 0, special, kb, ign_sv) && scr_canmove(dy, 0, special, kb, ign_sv);
790 }
791 1296 return true;
792 1535 }
793
794 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb)
795 {
796 zfix bx = dx+hxofs, by = dy+hyofs; //left/top
797 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
798
799 bool nosolid = !((moveflags & move_ignore_solidity) || (special==spw_wizzrobe) || (special==spw_floater));
800
801 if(nosolid && collide_object(bx,by,hit_width,hit_height,this))
802 return false;
803 for(zfix ty = 0; by+ty < ry; ty += 8)
804 {
805 for(zfix tx = 0; bx+tx < rx; tx += 8)
806 {
807 if(scr_walkflag(bx+tx, by+ty, special, -1, -1000, -1000, kb))
808 return false;
809 }
810 if(scr_walkflag(rx, by+ty, special, -1, -1000, -1000, kb))
811 return false;
812 }
813 for(zfix tx = 0; bx+tx < rx; tx += 8)
814 {
815 if(scr_walkflag(bx+tx, ry, special, -1, -1000, -1000, kb))
816 return false;
817 }
818 if(scr_walkflag(rx, ry, special, -1, -1000, -1000, kb))
819 return false;
820 return true;
821 }
822
823 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb, int32_t nwid, int32_t nhei)
824 {
825 auto oxsz = hit_width, oysz = hit_height;
826 if(nwid > -1) hit_width = nwid;
827 if(nhei > -1) hit_height = nhei;
828 bool ret = scr_canplace(dx,dy,special,kb);
829 hit_width = oxsz; hit_height = oysz;
830 return ret;
831 }
832
833 1311 bool enemy::movexy(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv, bool earlyret)
834 {
835 1311 bool ret = true;
836
3/8
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1019 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1311 if(!ign_sv && dy < 0 && (moveflags & move_obeys_grav) && isSideViewGravity())
837 dy = 0;
838 1311 const int scl = 2;
839
4/4
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 1345 times.
✓ Branch 2 taken 294 times.
✓ Branch 3 taken 1311 times.
1605 while(abs(dx) > scl || abs(dy) > scl)
840 {
841
2/2
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 34 times.
294 if(abs(dx) > abs(dy))
842 {
843 260 int32_t tdx = dx.sign() * scl;
844
1/2
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
260 if(movexy(tdx, 0, special, kb, ign_sv, earlyret))
845 260 dx -= tdx;
846 else
847 {
848 if(earlyret) return false;
849 dx = tdx;
850 ret = false;
851 }
852 260 }
853 else
854 {
855 34 int32_t tdy = dy.sign() * scl;
856
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 7 times.
34 if(movexy(0, tdy, special, kb, ign_sv, earlyret))
857 27 dy -= tdy;
858 else
859 {
860
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(earlyret) return false;
861 7 dy = tdy;
862 7 ret = false;
863 }
864 }
865 }
866
867
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 1111 times.
1311 if(dx)
868 {
869
2/2
✓ Branch 0 taken 1110 times.
✓ Branch 1 taken 1 times.
1111 if(scr_canmove(dx, 0, special, kb, ign_sv))
870 1110 x += dx;
871 else
872 {
873
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(earlyret) return false;
874 ret = false;
875 int xsign = dx.sign();
876 while(scr_canmove(xsign, 0, special, kb, ign_sv))
877 {
878 x += xsign;
879 dx -= xsign;
880 }
881 if(dx)
882 {
883 dx.doDecBound(0,-9999, 0,9999);
884 dx = binary_search_zfix(dx.decsign(), dx, [&](zfix val, zfix& retval){
885 if(scr_canmove(val, 0, special, kb, ign_sv))
886 {
887 retval = val;
888 return BSEARCH_CONTINUE_AWAY0;
889 }
890 else return BSEARCH_CONTINUE_TOWARD0;
891 });
892 x += dx;
893 }
894 }
895 1110 }
896
2/2
✓ Branch 0 taken 1110 times.
✓ Branch 1 taken 200 times.
1310 if(dy)
897 {
898
2/2
✓ Branch 0 taken 186 times.
✓ Branch 1 taken 14 times.
200 if(scr_canmove(0, dy, special, kb, ign_sv))
899 186 y += dy;
900 else
901 {
902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(earlyret) return false;
903 14 ret = false;
904 14 int ysign = dy.sign();
905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 while(scr_canmove(0, ysign, special, kb, ign_sv))
906 {
907 y += ysign;
908 dy -= ysign;
909 }
910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(dy)
911 {
912 14 dy.doDecBound(0,-9999, 0,9999);
913
3/6
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
224 dy = binary_search_zfix(dy.decsign(), dy, [&](zfix val, zfix& retval){
914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 210 times.
210 if(scr_canmove(0, val, special, kb, ign_sv))
915 {
916 retval = val;
917 return BSEARCH_CONTINUE_AWAY0;
918 }
919 210 else return BSEARCH_CONTINUE_TOWARD0;
920 210 });
921 14 y += dy;
922 14 }
923 }
924 200 }
925 1310 return ret;
926 1311 }
927
928 754 bool enemy::moveDir(int32_t dir, zfix px, int32_t special, bool kb, bool earlyret)
929 {
930
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 752 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
754 static const zfix diagrate = zslongToFix(7071);
931
5/13
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 754 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 479 times.
✓ Branch 7 taken 259 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
754 switch(NORMAL_DIR(dir))
932 {
933 case up:
934 return movexy(0, -px, special, kb, false, earlyret);
935 case down:
936 16 return movexy(0, px, special, kb, false, earlyret);
937 case left:
938 479 return movexy(-px, 0, special, kb, false, earlyret);
939 case right:
940 259 return movexy(px, 0, special, kb, false, earlyret);
941 case r_up:
942 return movexy(px*diagrate, -px*diagrate, special, kb, false, earlyret);
943 case r_down:
944 return movexy(px*diagrate, px*diagrate, special, kb, false, earlyret);
945 case l_up:
946 return movexy(-px*diagrate, -px*diagrate, special, kb, false, earlyret);
947 case l_down:
948 return movexy(-px*diagrate, px*diagrate, special, kb, false, earlyret);
949 }
950 return false;
951 754 }
952
953 bool enemy::moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb, bool earlyret)
954 {
955 double v = degrees.getFloat() * PI / 180.0;
956 zfix dx = zc::math::Cos(v)*px, dy = zc::math::Sin(v)*px;
957 return movexy(dx, dy, special, kb, false, earlyret);
958 }
959
960 bool enemy::can_movexy(zfix dx, zfix dy, int32_t special, bool kb)
961 {
962 zfix tx = x, ty = y;
963 bool ret = movexy(dx, dy, special, kb, false, true);
964 x = tx;
965 y = ty;
966 return ret;
967 }
968 754 bool enemy::can_moveDir(int32_t dir, zfix px, int32_t special, bool kb)
969 {
970 754 zfix tx = x, ty = y;
971 754 bool ret = moveDir(dir, px, special, kb, true);
972 754 x = tx;
973 754 y = ty;
974 754 return ret;
975 }
976 bool enemy::can_moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb)
977 {
978 zfix tx = x, ty = y;
979 bool ret = moveAtAngle(degrees, px, special, kb, true);
980 x = tx;
981 y = ty;
982 return ret;
983 }
984
985 // Handle pitfalls
986 38011691 bool enemy::do_falling(int32_t index)
987 {
988
2/2
✓ Branch 0 taken 38009324 times.
✓ Branch 1 taken 2367 times.
38011691 if(fallclk > 0)
989 {
990
4/4
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 2333 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 20 times.
2367 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x));
991
2/2
✓ Branch 0 taken 2345 times.
✓ Branch 1 taken 22 times.
2367 if(!--fallclk)
992 {
993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(immortal) //Keep alive forever
994 ++fallclk; //force another frame of falling.... forever.
995
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 11 times.
22 else if(dying) //Give 1 frame for script revival
996 {
997
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(flags&guy_never_return)
998 never_return(screen_spawned, index);
999
1000
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(leader)
1001 kill_em_all();
1002
1003 //leave_item(); //Don't drop items in pits!
1004 11 stop_bgsfx(index);
1005 11 return true;
1006 }
1007 else
1008 {
1009 11 try_death(true); //Force death
1010 11 ++fallclk; //force another frame of falling
1011 }
1012 11 }
1013
1014 2356 wpndata& spr = wpnsbuf[QMisc.sprites[sprFALL]];
1015 2356 cs = spr.csets & 0xF;
1016
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 int32_t fr = spr.frames ? spr.frames : 1;
1017
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 int32_t spd = spr.speed ? spr.speed : 1;
1018 2356 int32_t animclk = (PITFALL_FALL_FRAMES-fallclk);
1019
2/2
✓ Branch 0 taken 1148 times.
✓ Branch 1 taken 1208 times.
2356 tile = spr.tile + zc_min(animclk / spd, fr-1);
1020 2356 }
1021 38011680 return false;
1022 38011691 }
1023
1024 // Handle drowning in water
1025 38009324 bool enemy::do_drowning(int32_t index)
1026 {
1027
1/2
✓ Branch 0 taken 38009324 times.
✗ Branch 1 not taken.
38009324 if(drownclk > 0)
1028 {
1029 //if(drownclk == WATER_DROWN_FRAMES && drownCombo) sfx(combobuf[drownCombo].attribytes[0], pan(x));
1030 //!TODO: Drown SFX
1031 if(!--drownclk)
1032 {
1033 if(immortal) //Keep alive forever
1034 ++drownclk; //force another frame of falling.... forever.
1035 else if(dying) //Give 1 frame for script revival
1036 {
1037 if(flags&guy_never_return)
1038 never_return(screen_spawned, index);
1039
1040 if(leader)
1041 kill_em_all();
1042
1043 //leave_item(); //Don't drop items in pits!
1044 stop_bgsfx(index);
1045 return true;
1046 }
1047 else
1048 {
1049 try_death(true); //Force death
1050 ++drownclk; //force another frame of falling
1051 }
1052 }
1053
1054 bool lava = (drownCombo && combobuf[drownCombo].usrflags&cflag1);
1055 wpndata &spr = wpnsbuf[QMisc.sprites[lava ? sprLAVADROWN : sprDROWN]];
1056 cs = spr.csets & 0xF;
1057 int32_t fr = spr.frames ? spr.frames : 1;
1058 int32_t spd = spr.speed ? spr.speed : 1;
1059 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
1060 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
1061 }
1062 38009324 return false;
1063 38009324 }
1064
1065 // Supplemental animation code that all derived classes should call
1066 // as a return value for animate().
1067 // Handles the death animation and returns true when enemy is finished.
1068 38674710 bool enemy::Dead(int32_t index)
1069 {
1070
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 38672881 times.
38674710 if(immortal)
1071 {
1072 1829 dying = false;
1073 1829 return false;
1074 }
1075
2/2
✓ Branch 0 taken 765577 times.
✓ Branch 1 taken 37907304 times.
38672881 if(dying)
1076 {
1077
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 765576 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
765577 if(deathexstate > -1 && deathexstate < 32)
1078 {
1079 1 setxmapflag(screen_spawned, 1<<deathexstate);
1080 1 deathexstate = -1;
1081 1 }
1082 765577 --clk2;
1083
1084
4/4
✓ Branch 0 taken 725657 times.
✓ Branch 1 taken 39920 times.
✓ Branch 2 taken 38736 times.
✓ Branch 3 taken 3242 times.
765577 if((get_qr(qr_HARDCODED_ENEMY_ANIMS) && clk2==12)
1085
2/2
✓ Branch 0 taken 41978 times.
✓ Branch 1 taken 683679 times.
725657 && hp>-1000) // not killed by ringleader
1086 38736 death_sfx();
1087
1088
2/2
✓ Branch 0 taken 722043 times.
✓ Branch 1 taken 43534 times.
765577 if(clk2==0)
1089 {
1090
2/2
✓ Branch 0 taken 42830 times.
✓ Branch 1 taken 704 times.
43534 if(flags&guy_never_return)
1091 704 never_return(screen_spawned, index);
1092
1093
2/2
✓ Branch 0 taken 43463 times.
✓ Branch 1 taken 71 times.
43534 if(leader)
1094 71 kill_em_all();
1095
1096 43534 leave_item();
1097 43534 }
1098
1099 765577 stop_bgsfx(index);
1100 765577 return (clk2==0);
1101 }
1102
1103 37907304 return false;
1104 38674710 }
1105
1106 // Basic animation code that all derived classes should call.
1107 // The one with an index is the one that is called by
1108 // the guys sprite list; index is the enemy's index in the list.
1109 38011947 bool enemy::animate(int32_t index)
1110 {
1111 38011947 update_current_screen();
1112
2/2
✓ Branch 0 taken 1723938 times.
✓ Branch 1 taken 36288009 times.
38011947 if(sclk <= 0) hitdir = -1;
1113
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 38011691 times.
38011947 if(switch_hooked)
1114 {
1115
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(get_qr(qr_SWITCHOBJ_RUN_SCRIPT))
1116 {
1117 //Run its script
1118 if (!didScriptThisFrame)
1119 {
1120 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1121 {
1122 return 0; //Avoid NULLPO if this object deleted itself
1123 }
1124 }
1125 }
1126 256 return false;
1127 }
1128
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 38011680 times.
38011691 if(do_falling(index)) return true;
1129
2/2
✓ Branch 0 taken 2356 times.
✓ Branch 1 taken 38009324 times.
38011680 else if(fallclk)
1130 {
1131 //clks
1132
2/2
✓ Branch 0 taken 1652 times.
✓ Branch 1 taken 704 times.
2356 if(hclk>0)
1133 704 --hclk;
1134
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 if(stunclk>0)
1135 --stunclk;
1136
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 if ( frozenclock > 0 )
1137 --frozenclock;
1138
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 if(hashero)
1139 {
1140 Hero.setX(x);
1141 Hero.setY(y);
1142 Hero.fallCombo = fallCombo;
1143 Hero.fallclk = fallclk;
1144
1145 if(hashero)
1146 {
1147 hashero = false; //Let Hero go if falling
1148 Hero.setEaten(0);
1149 }
1150 }
1151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2356 times.
2356 if (!didScriptThisFrame)
1152 {
1153 2356 run_script(MODE_NORMAL);
1154 2356 }
1155 2356 return false;
1156 }
1157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38009324 times.
38009324 if(do_drowning(index)) return true;
1158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38009324 times.
38009324 else if(drownclk)
1159 {
1160 //clks
1161 if(hclk>0)
1162 --hclk;
1163 if(stunclk>0)
1164 --stunclk;
1165 if ( frozenclock > 0 )
1166 --frozenclock;
1167 if(hashero)
1168 {
1169 Hero.setX(x);
1170 Hero.setY(y);
1171 Hero.drownclk = drownclk;
1172
1173 if(hashero)
1174 {
1175 hashero = false; //Let Hero go if falling
1176 Hero.setEaten(0);
1177 }
1178 }
1179 if (!didScriptThisFrame)
1180 {
1181 run_script(MODE_NORMAL);
1182 }
1183 return false;
1184 }
1185 38009324 int32_t nx = real_x(x);
1186 38009324 int32_t ny = real_y(y);
1187
1188
4/4
✓ Branch 0 taken 27480339 times.
✓ Branch 1 taken 10528985 times.
✓ Branch 2 taken 5660595 times.
✓ Branch 3 taken 21819744 times.
38009324 if(ox!=nx || oy!=ny)
1189 {
1190 16189580 posframe=(posframe+1)%(get_qr(qr_NEWENEMYTILES)?4:2);
1191 16189580 }
1192
1193 38009324 ox = nx;
1194 38009324 oy = ny;
1195
1196 // Maybe they fell off the bottom in sideview, or were moved by a script.
1197
1198 //Check offscreen settings. I wrote it this way for clarity and to simplify testing. -Z
1199
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 38007495 times.
38009324 if ( immortal )
1200 {
1201 //skip, as it can go out of bounds, from immortality
1202 1829 }
1203
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 38007495 times.
✓ Branch 2 taken 38007495 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 38007495 times.
38007495 else if ( (moveflags & move_ignore_screenedge) || (( (get_qr(qr_OUTOFBOUNDSENEMIES)) != bool(editorflags&ENEMY_FLAG11) ) && !NEWOUTOFBOUNDS(x,y,z+fakez)) )
1204 {
1205 //skip, it can go out of bounds, from a quest rule, or from the enemy editor (but not both!)
1206 }
1207
2/2
✓ Branch 0 taken 37975894 times.
✓ Branch 1 taken 31601 times.
38007495 else if (OUTOFBOUNDS(id, x, y))
1208 {
1209 31601 hp=-1000; //kill it, as it is not immortal, and no quest bit or rule is enabled
1210 31601 }
1211 //fall down
1212 38009324 handle_termv();
1213
6/6
✓ Branch 0 taken 27192563 times.
✓ Branch 1 taken 10816761 times.
✓ Branch 2 taken 10546498 times.
✓ Branch 3 taken 27462826 times.
✓ Branch 4 taken 511441 times.
✓ Branch 5 taken 10035057 times.
38009324 if((enemycanfall(id) || (moveflags & move_obeys_grav) )&& fading != fade_flicker && clk>=0)
1214 {
1215
2/2
✓ Branch 0 taken 387698 times.
✓ Branch 1 taken 9647359 times.
10035057 if(isSideViewGravity())
1216 {
1217
1/2
✓ Branch 0 taken 387698 times.
✗ Branch 1 not taken.
387698 if(get_qr(qr_OLD_SIDEVIEW_LANDING_CODE))
1218 {
1219
2/2
✓ Branch 0 taken 230320 times.
✓ Branch 1 taken 157378 times.
387698 if(!isOnSideviewPlatform())
1220 {
1221 157378 bool willHitSVPlatform = false;
1222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157378 times.
157378 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH)?hit_width:16;
1223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157378 times.
157378 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT)?hit_height:16;
1224
2/2
✓ Branch 0 taken 157378 times.
✓ Branch 1 taken 157378 times.
314756 for(int32_t nx = x+4; nx < x+usewid; nx+=16)
1225 {
1226
5/8
✓ Branch 0 taken 23519 times.
✓ Branch 1 taken 133859 times.
✓ Branch 2 taken 23519 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23519 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 157378 times.
✗ Branch 7 not taken.
157378 if(fall > 0 && !IGNORE_SIDEVIEW_PLATFORMS && checkSVLadderPlatform(x+4,y+(fall/100)+usehei-1) && (((int32_t(y)+(int32_t(fall)/100)+usehei-1)&0xF0)!=((int32_t(y)+usehei-1)&0xF0)))
1227 {
1228 willHitSVPlatform = true;
1229 break;
1230 }
1231 157378 }
1232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157378 times.
157378 if(willHitSVPlatform)
1233 {
1234 y+=fall/100;
1235 //y-=int32_t(y)%16; //Fix to top of SV Ladder
1236 do_fix(y, 16); //Fix to top of SV Ladder
1237 fall = 0;
1238 }
1239 else
1240 {
1241 157378 y+=fall/100;
1242
2/2
✓ Branch 0 taken 17812 times.
✓ Branch 1 taken 139566 times.
157378 if(fall <= get_terminalv_fall())
1243 139566 fall += get_grav_fall();
1244 }
1245 157378 }
1246 else
1247 {
1248
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 230043 times.
230320 if(fall!=0) // Only fix pos once
1249 {
1250 //y-=(int32_t)y%8; // Fix position
1251 277 do_fix(y, 8); //Fix position
1252 277 }
1253
1254 230320 fall = 0;
1255 }
1256 387698 }
1257 else
1258 {
1259 if(isOnSideviewPlatform())
1260 fall = 0;
1261 else
1262 {
1263 zfix fall_amnt = fall/100;
1264 bool hit = false;
1265 while(fall_amnt >= 1)
1266 {
1267 --fall_amnt;
1268 ++y;
1269 if(isOnSideviewPlatform())
1270 {
1271 y = y.getInt();
1272 fall_amnt = 0;
1273 hit = true;
1274 break;
1275 }
1276 }
1277 if(fall_amnt > 0)
1278 y += fall_amnt;
1279 if(fall_amnt < 0)
1280 {
1281 if(!movexy(0,fall_amnt,spw_none,false,!get_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP)))
1282 hit = true;
1283 }
1284 if(hit)
1285 fall = 0;
1286 else if(fall <= get_terminalv_fall())
1287 fall += get_grav_fall();
1288 }
1289 }
1290 387698 }
1291 else
1292 {
1293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9647359 times.
9647359 if (!(moveflags & move_no_fake_z))
1294 {
1295
2/2
✓ Branch 0 taken 5079296 times.
✓ Branch 1 taken 4568063 times.
9647359 if(fakefall!=0)
1296 4568063 fakez-=(fakefall/100);
1297
1298
2/2
✓ Branch 0 taken 4568063 times.
✓ Branch 1 taken 5079296 times.
9647359 if(fakez<0)
1299 4568063 fakez = fakefall = 0;
1300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5079296 times.
5079296 else if(fakefall <= get_terminalv_fall())
1301 5079296 fakefall += get_grav_fall();
1302
1303
5/6
✓ Branch 0 taken 9647359 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5079296 times.
✓ Branch 3 taken 4568063 times.
✓ Branch 4 taken 4582310 times.
✓ Branch 5 taken 496986 times.
9647359 if (fakez<=0 && fakefall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fakefall = 0;
1304 9647359 }
1305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9647359 times.
9647359 if (!(moveflags & move_no_real_z))
1306 {
1307
2/2
✓ Branch 0 taken 5512182 times.
✓ Branch 1 taken 4135177 times.
9647359 if(fall!=0)
1308 4135177 z-=(fall/100);
1309
1310
2/2
✓ Branch 0 taken 4120605 times.
✓ Branch 1 taken 5526754 times.
9647359 if(z<0)
1311 4120605 z = fall = 0;
1312
2/2
✓ Branch 0 taken 10057 times.
✓ Branch 1 taken 5516697 times.
5526754 else if(fall <= get_terminalv_fall())
1313 5516697 fall += get_grav_fall();
1314
1315
6/6
✓ Branch 0 taken 9605145 times.
✓ Branch 1 taken 42214 times.
✓ Branch 2 taken 5484540 times.
✓ Branch 3 taken 4120605 times.
✓ Branch 4 taken 4990689 times.
✓ Branch 5 taken 493851 times.
9647359 if (z<=0 && fall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fall = 0;
1316 9647359 }
1317
1318 }
1319 10035057 }
1320 38009324 handle_termv();
1321
9/10
✓ Branch 0 taken 29780223 times.
✓ Branch 1 taken 8229101 times.
✓ Branch 2 taken 28485223 times.
✓ Branch 3 taken 1295000 times.
✓ Branch 4 taken 28485223 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4179477 times.
✓ Branch 7 taken 25600746 times.
✓ Branch 8 taken 18452882 times.
✓ Branch 9 taken 22632359 times.
38009324 if (can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
1322 {
1323
4/4
✓ Branch 0 taken 22216835 times.
✓ Branch 1 taken 415524 times.
✓ Branch 2 taken 13056224 times.
✓ Branch 3 taken 9160611 times.
22632359 if (!isSideViewGravity() && (moveflags & move_can_pitfall))
1324 9160611 fallCombo = check_pits();
1325
4/4
✓ Branch 0 taken 415524 times.
✓ Branch 1 taken 22216835 times.
✓ Branch 2 taken 141898 times.
✓ Branch 3 taken 22074937 times.
22632359 if (!(isSideViewGravity() && get_qr(qr_OLD_SPRITE_FALL_DROWN)) && (moveflags & move_can_waterdrown))
1326 141898 drownCombo = check_water();
1327 22632359 }
1328
1329 74915088 runKnockback(); //scripted knockback handling
1330
1331 // clk is incremented here
1332
2/2
✓ Branch 0 taken 72604719 times.
✓ Branch 1 taken 2310369 times.
74915088 if(++clk >= frate)
1333 2310369 clk=0;
1334
1335 // hit and death handling
1336
2/2
✓ Branch 0 taken 1255709 times.
✓ Branch 1 taken 73659379 times.
74915088 if(hclk>0)
1337 1255709 --hclk;
1338
1339
2/2
✓ Branch 0 taken 676245 times.
✓ Branch 1 taken 74238843 times.
74915088 if(stunclk>0)
1340 676245 --stunclk;
1341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74915088 times.
74915088 if ( frozenclock > 0 )
1342 --frozenclock;
1343
1344
5/6
✓ Branch 0 taken 14876 times.
✓ Branch 1 taken 74900212 times.
✓ Branch 2 taken 124 times.
✓ Branch 3 taken 14752 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 124 times.
74915088 if(ceiling && z <= 0 && fakez <= 0)
1345 124 ceiling = false;
1346
1347 74915088 try_death();
1348
1349 74915088 scored=false;
1350
1351 74915088 ++c_clk;
1352
1353 //Run its script
1354
2/2
✓ Branch 0 taken 36930581 times.
✓ Branch 1 taken 37984507 times.
74915088 if (!didScriptThisFrame)
1355 {
1356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37984507 times.
37984507 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1357 {
1358 return 0; //Avoid NULLPO if this object deleted itself
1359 }
1360 37984507 }
1361
1362 // returns true when enemy is defeated
1363 74915088 return Dead(index);
1364 74917711 }
1365
1366 38761623 bool enemy::setSolid(bool set)
1367 {
1368
1/2
✓ Branch 0 taken 38761623 times.
✗ Branch 1 not taken.
38761623 bool actual = set && !isSubmerged();
1369 38761623 bool ret = solid_object::setSolid(actual);
1370 38761623 solid = set;
1371 38761623 return ret;
1372 }
1373 void enemy::doContactDamage(int32_t hdir)
1374 {
1375 Hero.hithero(guys.find(this), hdir);
1376 }
1377
1378 22405 void enemy::solid_push(solid_object *obj)
1379 {
1380
1/2
✓ Branch 0 taken 22405 times.
✗ Branch 1 not taken.
22405 if(obj == this) return; //can't push self
1381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22405 times.
22405 if(moveflags&move_not_pushable) return; //not pushable
1382 22405 zfix dx, dy;
1383 22405 int32_t hdir = -1;
1384 22405 solid_push_int(obj,dx,dy,hdir,true);
1385
1386
4/4
✓ Branch 0 taken 22292 times.
✓ Branch 1 taken 113 times.
✓ Branch 2 taken 150 times.
✓ Branch 3 taken 22142 times.
22405 if(!dx && !dy) return;
1387
1388 263 bool t = obj->getTempNonsolid();
1389 263 obj->setTempNonsolid(true);
1390
1391 263 int32_t ydir = dy > 0 ? down : up;
1392 263 int32_t xdir = dx > 0 ? right : left;
1393
1394 263 auto special = isflier(id) ? spw_floater : spw_none;
1395
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 7 times.
263 if(!movexy(dx,dy,special,true,true))
1396 {
1397 //Crushed?
1398 7 }
1399
1400 263 obj->setTempNonsolid(t);
1401 22405 }
1402 22405 bool enemy::is_unpushable() const
1403 {
1404 22405 return isSubmerged();
1405 }
1406 22087 bool enemy::sideview_mode() const
1407 {
1408
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 22087 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
22087 return isSideViewGravity() && (moveflags&move_obeys_grav) && !(moveflags&move_not_pushable);
1409 }
1410
1411 3234 bool enemy::m_walkflag_old(int32_t dx,int32_t dy,int32_t special, int32_t x, int32_t y)
1412 {
1413 3234 int32_t yg = (special==spw_floater)?8:0;
1414 3234 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1415
1416
8/10
✓ Branch 0 taken 2364 times.
✓ Branch 1 taken 870 times.
✓ Branch 2 taken 814 times.
✓ Branch 3 taken 56 times.
✓ Branch 4 taken 870 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 870 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2368 times.
✓ Branch 9 taken 3238 times.
3234 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=world_w-16+nb || dy>=world_h-16+nb)
1417 4732 return true;
1418
1419 3238 bool isInDungeon = isdungeon(screen_spawned);
1420
3/4
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 2976 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 262 times.
3238 if(isInDungeon || special==spw_wizzrobe)
1421 {
1422
7/8
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 2375 times.
✓ Branch 2 taken 595 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 604 times.
✓ Branch 5 taken 1779 times.
✓ Branch 6 taken 604 times.
✗ Branch 7 not taken.
2976 if((x>=32 && dy<32-yg) || (y>-1000 && y<=144 && dy>=144))
1423 1199 return true;
1424
1425
7/8
✓ Branch 0 taken 592 times.
✓ Branch 1 taken 1187 times.
✓ Branch 2 taken 595 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 595 times.
✓ Branch 5 taken 595 times.
✓ Branch 6 taken 595 times.
✗ Branch 7 not taken.
1779 if((x>=32 && dx<32) || (x>-1000 && x<224 && dx>=224))
1426
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
1190 if(special!=spw_door) // walk in door way
1427 return true;
1428 595 }
1429
1430
3/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 795 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
857 if(!(moveflags & move_can_pitwalk) && !(moveflags & move_can_pitfall)) //Don't walk into pits (knockback doesn't call this func)
1431 {
1432
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
124 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1433
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1434 return true;
1435 62 }
1436
1437
1/4
✓ Branch 0 taken 857 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
857 switch(special)
1438 {
1439 case spw_clipbottomright:
1440 if(dy>=128 || dx>=208) return true;
1441 break;
1442 case spw_clipright:
1443 break; //if(x>=208) return true; break;
1444
1445 case spw_wizzrobe: // fall through
1446 case spw_floater: // Special case for fliers and wizzrobes - hack!
1447 {
1448
2/2
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 595 times.
857 if(isInDungeon)
1449 {
1450
2/4
✓ Branch 0 taken 595 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 595 times.
595 if(dy < 32-yg || dy >= 144) return true;
1451
2/4
✓ Branch 0 taken 595 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 595 times.
595 if(dx < 32 || dx >= 224) return true;
1452 595 }
1453 857 return false;
1454 }
1455 }
1456
1457 dx = CLEAR_LOW_BITS(dx, special == spw_halfstep ? 3 : 4);
1458 dy = CLEAR_LOW_BITS(dy, special == spw_halfstep || isSideViewGravity() ? 3 : 4);
1459
1460 if(special==spw_water)
1461 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1462
1463 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1464 groundblocked(dx,dy+8) || groundblocked(dx+8,dy+8);
1465 870 }
1466
1467 6575 bool enemy::m_walkflag_simple(int32_t dx,int32_t dy)
1468 {
1469 6575 bool kb = false;
1470 6575 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1471
1472
5/10
✗ Branch 0 not taken.
✓ Branch 1 taken 6575 times.
✓ Branch 2 taken 6575 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6575 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6575 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 6575 times.
6575 if(dx<16-nb || dy<zc_max(16-nb,0) || dx>=world_w-16+nb || dy>=world_h-16+nb)
1473 return true;
1474
1475
2/2
✓ Branch 0 taken 5062 times.
✓ Branch 1 taken 1513 times.
6575 if(isdungeon(screen_spawned))
1476 {
1477
2/4
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1513 times.
1513 if((dy<32) || (dy>=world_h-32))
1478 return true;
1479
1480
2/4
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1513 times.
1513 if((dx<32) || (dx>=world_w-32))
1481 return true;
1482 1513 }
1483
1484
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6575 times.
6575 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall))) //Don't walk into pits, unless being knocked back
1485 {
1486
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6575 times.
13150 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1487
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6575 times.
✗ Branch 3 not taken.
6575 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1488 return true;
1489 6575 }
1490
1491
2/2
✓ Branch 0 taken 6545 times.
✓ Branch 1 taken 30 times.
6575 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1492 {
1493
3/4
✓ Branch 0 taken 2657 times.
✓ Branch 1 taken 3888 times.
✓ Branch 2 taken 2657 times.
✗ Branch 3 not taken.
9202 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2657 times.
2657 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1495 }
1496 else
1497 {
1498
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
60 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1499
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1500
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1502 }
1503 6575 }
1504
1505 // returns true if cannot walk
1506 32505729 bool enemy::m_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
1507 {
1508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32505729 times.
32505729 if(moveflags & move_new_movement)
1509 return scr_walkflag(dx,dy,special,dir,input_x,input_y,kb);
1510 32505729 int32_t yg = (special==spw_floater)?8:0;
1511 32505729 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1512
2/2
✓ Branch 0 taken 3724406 times.
✓ Branch 1 taken 28781323 times.
32505729 switch(dir)
1513 {
1514 case l_down:
1515 case r_down:
1516 case down:
1517 case 11: //r_down
1518 case 12: //down
1519 case 13: //l_down
1520 {
1521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3724406 times.
3724406 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1522 {
1523
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 3724398 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
3724406 if ( SIZEflags&OVERRIDE_HIT_HEIGHT && !isflier(id) )
1524 {
1525 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1526
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 dy += zc_max(hit_height-16,0);
1527 8 }
1528 3724406 }
1529 3724406 break;
1530 }
1531 }
1532
2/2
✓ Branch 0 taken 3726357 times.
✓ Branch 1 taken 28779372 times.
32505729 switch(dir)
1533 {
1534 case r_up:
1535 case r_down:
1536 case right:
1537 case 9: //r_up
1538 case 10: //right
1539 case 11: //r_down
1540 {
1541
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3726357 times.
3726357 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1542 {
1543
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3726354 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
3726357 if ( SIZEflags&OVERRIDE_HIT_WIDTH && !isflier(id) )
1544 {
1545 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1546
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 dx += zc_max(hit_width-16,0);
1547 3 }
1548 3726357 }
1549 3726357 break;
1550 }
1551 }
1552
1553
10/10
✓ Branch 0 taken 22401875 times.
✓ Branch 1 taken 10103854 times.
✓ Branch 2 taken 8754457 times.
✓ Branch 3 taken 1349397 times.
✓ Branch 4 taken 10066678 times.
✓ Branch 5 taken 37176 times.
✓ Branch 6 taken 10043475 times.
✓ Branch 7 taken 23203 times.
✓ Branch 8 taken 22454867 times.
✓ Branch 9 taken 32498342 times.
32505729 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=world_w-16+nb || dy>=world_h-16+nb)
1554 44917121 return true;
1555
1556 32498342 bool isInDungeon = isdungeon(screen_spawned);
1557
4/4
✓ Branch 0 taken 3976583 times.
✓ Branch 1 taken 28521759 times.
✓ Branch 2 taken 11756 times.
✓ Branch 3 taken 3964827 times.
32498342 if(isInDungeon || special==spw_wizzrobe)
1558 {
1559
8/8
✓ Branch 0 taken 5892236 times.
✓ Branch 1 taken 22641279 times.
✓ Branch 2 taken 5667745 times.
✓ Branch 3 taken 224491 times.
✓ Branch 4 taken 5820349 times.
✓ Branch 5 taken 17045421 times.
✓ Branch 6 taken 5820162 times.
✓ Branch 7 taken 187 times.
28533515 if((input_x>=32 && dy<32-yg) || (input_y>-1000 && input_y<=world_h-32 && dy>=world_h-32))
1560 11487907 return true;
1561
1562
8/8
✓ Branch 0 taken 5739852 times.
✓ Branch 1 taken 11305756 times.
✓ Branch 2 taken 5573332 times.
✓ Branch 3 taken 166520 times.
✓ Branch 4 taken 5688285 times.
✓ Branch 5 taken 5783991 times.
✓ Branch 6 taken 5687331 times.
✓ Branch 7 taken 954 times.
17045608 if((input_x>=32 && dx<32) || (input_x>-1000 && input_x<world_w-32 && dx>=world_w-32))
1563
2/2
✓ Branch 0 taken 113905 times.
✓ Branch 1 taken 94 times.
11260663 if(special!=spw_door) // walk in door way
1564 113905 return true;
1565 5785039 }
1566
1567
6/6
✓ Branch 0 taken 3102356 times.
✓ Branch 1 taken 6647510 times.
✓ Branch 2 taken 750728 times.
✓ Branch 3 taken 2351628 times.
✓ Branch 4 taken 51230 times.
✓ Branch 5 taken 699498 times.
9749866 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !kb)) //Don't walk into pits, unless being knocked back
1568 {
1569
4/4
✓ Branch 0 taken 3044709 times.
✓ Branch 1 taken 6417 times.
✓ Branch 2 taken 50 times.
✓ Branch 3 taken 3043757 times.
6094933 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1570
4/4
✓ Branch 0 taken 3044526 times.
✓ Branch 1 taken 183 times.
✓ Branch 2 taken 3043807 times.
✓ Branch 3 taken 719 times.
3044709 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1571 7369 return true;
1572 3043757 }
1573
1574
4/4
✓ Branch 0 taken 7555697 times.
✓ Branch 1 taken 2180546 times.
✓ Branch 2 taken 973 times.
✓ Branch 3 taken 5281 times.
9742497 switch(special)
1575 {
1576 case spw_clipbottomright:
1577
4/4
✓ Branch 0 taken 786 times.
✓ Branch 1 taken 187 times.
✓ Branch 2 taken 79 times.
✓ Branch 3 taken 707 times.
973 if(dy>=world_h-48 || dx>=world_w-48) return true;
1578 707 break;
1579 case spw_clipright:
1580 5281 break; //if(input_x>=208) return true; break;
1581
1582 case spw_wizzrobe: // fall through
1583 case spw_floater: // Special case for fliers and wizzrobes - hack!
1584 {
1585
2/2
✓ Branch 0 taken 2914018 times.
✓ Branch 1 taken 4641679 times.
7555697 if(isInDungeon)
1586 {
1587
3/4
✓ Branch 0 taken 4641667 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4641667 times.
4641679 if(dy < 32-yg || dy >= world_h-32) return true;
1588
4/4
✓ Branch 0 taken 4639555 times.
✓ Branch 1 taken 2112 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4639539 times.
4641667 if(dx < 32 || dx >= world_w-32) return true;
1589 4639539 }
1590 7553557 return false;
1591 }
1592 }
1593
1594 2186534 dx = CLEAR_LOW_BITS(dx, special == spw_halfstep ? 3 : 4);
1595
2/2
✓ Branch 0 taken 486589 times.
✓ Branch 1 taken 1699945 times.
2186534 dy = CLEAR_LOW_BITS(dy, special == spw_halfstep || isSideViewGravity() ? 3 : 4);
1596
1597
2/2
✓ Branch 0 taken 414677 times.
✓ Branch 1 taken 1771857 times.
2186534 if(special==spw_water)
1598
2/2
✓ Branch 0 taken 16749 times.
✓ Branch 1 taken 397928 times.
414677 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1599
1600
2/2
✓ Branch 0 taken 1711908 times.
✓ Branch 1 taken 59949 times.
1771857 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1601 {
1602
4/4
✓ Branch 0 taken 1228217 times.
✓ Branch 1 taken 483691 times.
✓ Branch 2 taken 1218180 times.
✓ Branch 3 taken 10037 times.
2930088 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1603
2/2
✓ Branch 0 taken 14580 times.
✓ Branch 1 taken 1203600 times.
1218180 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1604 }
1605 else
1606 {
1607
4/4
✓ Branch 0 taken 42909 times.
✓ Branch 1 taken 17040 times.
✓ Branch 2 taken 42645 times.
✓ Branch 3 taken 264 times.
102594 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1608
3/4
✓ Branch 0 taken 42282 times.
✓ Branch 1 taken 363 times.
✓ Branch 2 taken 42282 times.
✗ Branch 3 not taken.
42645 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1609
4/4
✓ Branch 0 taken 37047 times.
✓ Branch 1 taken 5235 times.
✓ Branch 2 taken 37032 times.
✓ Branch 3 taken 15 times.
42282 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1610
2/2
✓ Branch 0 taken 36729 times.
✓ Branch 1 taken 303 times.
37032 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1611 }
1612 10129559 }
1613
1614 496901 bool enemy::isOnSideviewPlatform()
1615 {
1616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 496901 times.
496901 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
1617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 496901 times.
496901 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
1618
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 496901 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
496901 if(!get_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP)&&fall<0)
1619 return false;
1620
5/6
✓ Branch 0 taken 11630 times.
✓ Branch 1 taken 485271 times.
✓ Branch 2 taken 422 times.
✓ Branch 3 taken 11208 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 422 times.
496901 if(y + usehei >= world_h && cur_screen>=0x70 && !(get_scr_for_world_xy(x, y)->flags2&wfDOWN)) return true; //Bottom of the map
1621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 496479 times.
496479 if(check_slope(x, y+1, usewid, usehei)) return true;
1622
2/2
✓ Branch 0 taken 496479 times.
✓ Branch 1 taken 215641 times.
712120 for(int32_t nx = x + 4; nx <= x + usewid - 4; nx+=16)
1623 {
1624
2/2
✓ Branch 0 taken 215641 times.
✓ Branch 1 taken 280838 times.
496479 if(_walkflag(nx,y+usehei,1)) return true;
1625
3/4
✓ Branch 0 taken 215641 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 151313 times.
✓ Branch 3 taken 64328 times.
215641 if(IGNORE_SIDEVIEW_PLATFORMS || ((int32_t(y)+usehei)%16)!=0) continue;
1626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64328 times.
64328 if(checkSVLadderPlatform(nx,y+usehei)) return true;
1627 64328 }
1628 215641 return false;
1629 496901 }
1630
1631 // Stops playing the given sound only if there are no enemies left to play it
1632 768489 void enemy::stop_bgsfx(int32_t index)
1633 {
1634
2/2
✓ Branch 0 taken 753379 times.
✓ Branch 1 taken 15110 times.
768489 if(bgsfx<=0)
1635 753379 return;
1636
1637 // Look for other enemies with the same bgsfx
1638
2/2
✓ Branch 0 taken 52994 times.
✓ Branch 1 taken 8806 times.
61800 for(int32_t i=0; i<guys.Count(); i++)
1639 {
1640
4/4
✓ Branch 0 taken 41902 times.
✓ Branch 1 taken 11092 times.
✓ Branch 2 taken 6304 times.
✓ Branch 3 taken 35598 times.
52994 if(i!=index && ((enemy*)guys.spr(i))->bgsfx==bgsfx)
1641 6304 return;
1642 46690 }
1643
1644 8806 stop_sfx(bgsfx);
1645 768489 }
1646
1647
1648 // to allow for different sfx on defeating enemy
1649 40356 void enemy::death_sfx()
1650 {
1651
2/2
✓ Branch 0 taken 40071 times.
✓ Branch 1 taken 285 times.
40356 if(deadsfx > 0) sfx(deadsfx,pan(x));
1652 40356 }
1653
1654 void enemy::move(zfix dx,zfix dy)
1655 {
1656 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !(moveflags & move_obeys_grav) || !enemycanfall(id)))
1657 {
1658 x+=dx;
1659 y+=dy;
1660 }
1661 }
1662
1663 18374579 void enemy::move(zfix s)
1664 {
1665
9/10
✓ Branch 0 taken 18374540 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 109109 times.
✓ Branch 3 taken 18265431 times.
✓ Branch 4 taken 58221 times.
✓ Branch 5 taken 50888 times.
✓ Branch 6 taken 1005 times.
✓ Branch 7 taken 57216 times.
✓ Branch 8 taken 1005 times.
✗ Branch 9 not taken.
18374579 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !enemycanfall(id) || !(moveflags & move_obeys_grav)))
1666 {
1667 18373535 sprite::move(s);
1668 18373535 }
1669 18374579 }
1670
1671 43836 void enemy::leave_item()
1672 {
1673 43836 int32_t drop_item = select_dropitem(item_set, x, y);
1674 43836 int32_t thedropset = item_set;
1675
1676 43836 std::vector<int32_t> &ev = FFCore.eventData;
1677 43836 ev.clear();
1678 43836 ev.push_back(getUID());
1679 43836 ev.push_back(drop_item*10000);
1680 43836 ev.push_back(thedropset*10000);
1681
1682 43836 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_1);
1683 43836 drop_item = vbound(ev[1] / 10000,-2,255);
1684 43836 thedropset = ev[2] / 10000;
1685 43836 ev.clear();
1686
1/2
✓ Branch 0 taken 43836 times.
✗ Branch 1 not taken.
43836 if(drop_item == -2)
1687 {
1688 drop_item = select_dropitem(thedropset,x,y);
1689 }
1690
1691
6/6
✓ Branch 0 taken 16545 times.
✓ Branch 1 taken 27291 times.
✓ Branch 2 taken 917 times.
✓ Branch 3 taken 15628 times.
✓ Branch 4 taken 169 times.
✓ Branch 5 taken 748 times.
43836 if(drop_item>=0&&((itemsbuf[drop_item].type!=itype_fairy)||!m_walkflag(x,y,0,dir)))
1692 {
1693 item* itm;
1694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16376 times.
16376 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
1695 {
1696 itm = (new item(x+hxofs+(hit_width/2)-8,y+hyofs+(hit_height/2)-8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1697 }
1698 else
1699 {
1700
8/14
✓ Branch 0 taken 1720 times.
✓ Branch 1 taken 14656 times.
✓ Branch 2 taken 1720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1720 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1720 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1720 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1720 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1720 times.
✗ Branch 13 not taken.
16376 if(extend >= 3) itm = (new item(x+(txsz-1)*8,y+(tysz-1)*8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1701
4/8
✓ Branch 0 taken 14656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14656 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14656 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14656 times.
✗ Branch 7 not taken.
14656 else itm = (new item(x,y,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1702 }
1703 16376 itm->from_dropset = thedropset;
1704 16376 add_item_for_screen(screen_spawned, itm);
1705
1706 16376 ev.push_back(getUID());
1707 16376 ev.push_back(itm->getUID());
1708
1709 16376 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_2);
1710 16376 ev.clear();
1711 16376 }
1712 43836 }
1713
1714 // auomatically kill off enemy (for rooms with ringleaders)
1715 411 void enemy::kickbucket()
1716 {
1717
3/4
✓ Branch 0 taken 379 times.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 379 times.
✗ Branch 3 not taken.
411 if(!superman && !(flags&guy_ignore_kill_all))
1718 379 hp=-1000; // don't call death_sfx()
1719 411 }
1720
1721 21250 bool enemy::isSubmerged() const
1722 {
1723 21250 return submerged;
1724 //!TODO SOLIDPUSH more things like teleporting wizzrobes
1725 }
1726
1727 20952 void enemy::FireBreath(bool seekhero)
1728 {
1729
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if(wpn==wNone)
1730 return;
1731
1732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20952 times.
20952 if(wpn==ewFireTrail)
1733 {
1734 dmisc1 = e1tEACHTILE;
1735 FireWeapon();
1736 return;
1737 }
1738
1739 20952 float fire_angle=0.0;
1740 20952 int32_t wx=0, wy=0, wdir=dir, xoff=0, yoff=0;
1741
1742
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if (SIZEflags & OVERRIDE_HIT_WIDTH)
1743 {
1744 xoff += hxofs;
1745 if (weap_data.override_flags & OVERRIDE_HIT_WIDTH)
1746 xoff += (hit_width / 2) - (weap_data.tilew * 8);
1747 else
1748 xoff += (hit_width / 2) - 8;
1749 }
1750
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
1751 {
1752 yoff += hyofs;
1753 if (weap_data.override_flags & OVERRIDE_HIT_HEIGHT)
1754 yoff += (hit_height / 2) - (weap_data.tileh * 8);
1755 else
1756 yoff += (hit_height / 2) - 8;
1757 }
1758
1759
2/2
✓ Branch 0 taken 5081 times.
✓ Branch 1 taken 15871 times.
20952 if(!seekhero)
1760 {
1761
4/5
✓ Branch 0 taken 3297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3079 times.
✓ Branch 3 taken 5287 times.
✓ Branch 4 taken 4208 times.
15871 switch(dir)
1762 {
1763 case down:
1764 3079 fire_angle=PI*(int64_t(zc_oldrand()%20)+10)/40;
1765 3079 wx=x;
1766 3079 wy=y+8;
1767 3079 break;
1768
1769 case -1:
1770 case up:
1771 3297 fire_angle=PI*(int64_t(zc_oldrand()%20)+50)/40;
1772 3297 wx=x;
1773 3297 wy=y-8;
1774 3297 break;
1775
1776 case left:
1777 5287 fire_angle=PI*(int64_t(zc_oldrand()%20)+30)/40;
1778 5287 wx=x-8;
1779 5287 wy=y;
1780 5287 break;
1781
1782 case right:
1783 4208 fire_angle=PI*(int64_t(zc_oldrand()%20)+70)/40;
1784 4208 wx=x+8;
1785 4208 wy=y;
1786 4208 break;
1787 }
1788
1789
3/4
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 15735 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
15871 if(wpn==ewFlame || wpn==ewFlame2)
1790 {
1791
2/4
✓ Branch 0 taken 15735 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15735 times.
15735 if(fire_angle==-PI || fire_angle==PI) wdir=left;
1792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==-PI/2) wdir=up;
1793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==PI/2) wdir=down;
1794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==0) wdir=right;
1795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle<-PI/2) wdir=l_up;
1796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle<0) wdir=r_up;
1797
2/2
✓ Branch 0 taken 1498 times.
✓ Branch 1 taken 14237 times.
15735 else if(fire_angle<(PI/2)) wdir=r_down;
1798
2/2
✓ Branch 0 taken 10121 times.
✓ Branch 1 taken 4116 times.
14237 else if(fire_angle<PI) wdir=l_down;
1799 15735 }
1800 15871 }
1801 else
1802 {
1803 5081 wx = x;
1804 5081 wy = y;
1805 }
1806
1807
2/2
✓ Branch 0 taken 5081 times.
✓ Branch 1 taken 15871 times.
20952 addEwpn(wx+xoff,wy+yoff,z,wpn,2,wdp,seekhero ? 0xFF : wdir, getUID(), 0, fakez);
1808 20952 sfx(wpnsfx(wpn),pan(x));
1809
1810 20952 int32_t i=Ewpns.Count()-1;
1811 20952 weapon *ew = (weapon*)(Ewpns.spr(i));
1812 20952 ew->moveflags &= ~move_can_pitfall; //No falling in pits
1813
1814
4/4
✓ Branch 0 taken 15871 times.
✓ Branch 1 taken 5081 times.
✓ Branch 2 taken 7914 times.
✓ Branch 3 taken 7957 times.
20952 if(!seekhero && (zc_oldrand()&4))
1815 {
1816 7957 ew->angular=true;
1817 7957 ew->angle=fire_angle;
1818 7957 }
1819
1820
4/4
✓ Branch 0 taken 20676 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 317 times.
✓ Branch 3 taken 20359 times.
20952 if(wpn==ewFlame && wpnsbuf[ewFLAME].frames>1)
1821 {
1822 20359 ew->aframe=zc_oldrand()%wpnsbuf[ewFLAME].frames;
1823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20359 times.
20359 if ( ew->do_animation ) ew->tile+=ew->aframe;
1824 20359 }
1825
1826
2/2
✓ Branch 0 taken 20952 times.
✓ Branch 1 taken 766199 times.
787151 for(int32_t j=Ewpns.Count()-1; j>0; j--)
1827 {
1828 766199 Ewpns.swap(j,j-1);
1829 766199 }
1830 20952 }
1831
1832 44662 void enemy::FireWeapon()
1833 {
1834 /*
1835 * Type:
1836 * 0x01: Boss fireball
1837 * 0x02: Seeks Hero
1838 * 0x04: Fast projectile
1839 * 0x00-0x30: If 0x02, slants toward (type>>3)-1
1840 */
1841
1842
2/2
✓ Branch 0 taken 44531 times.
✓ Branch 1 taken 131 times.
44662 if (wpn < 1) return;
1843
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 44531 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
44531 if(wpn<wEnemyWeapons && dmisc1!=9 && dmisc1!=10 && (wpn < wScript1 && wpn > wScript10) ) // Summoning doesn't require weapons
1844 return;
1845
1846
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 44531 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
44531 if(wpn==ewFireTrail && dmisc1>=e1t3SHOTS && dmisc1<=e1t8SHOTS)
1847 dmisc1 = e1tEACHTILE;
1848
1849 44531 int32_t xoff = 0;
1850 44531 int32_t yoff = 0;
1851
1/2
✓ Branch 0 taken 44531 times.
✗ Branch 1 not taken.
44531 if (SIZEflags & OVERRIDE_HIT_WIDTH)
1852 {
1853 xoff += hxofs;
1854 if (weap_data.override_flags & OVERRIDE_HIT_WIDTH)
1855 xoff += (hit_width / 2) - (weap_data.tilew * 8);
1856 else
1857 xoff += (hit_width / 2) - 8;
1858 }
1859
1/2
✓ Branch 0 taken 44531 times.
✗ Branch 1 not taken.
44531 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
1860 {
1861 yoff += hyofs;
1862 if (weap_data.override_flags & OVERRIDE_HIT_HEIGHT)
1863 yoff += (hit_height / 2) - (weap_data.tileh * 8);
1864 else
1865 yoff += (hit_height / 2) - 8;
1866 }
1867
1868 // TODO(crash): check that .add succeeds.
1869
1870
5/8
✓ Branch 0 taken 646 times.
✓ Branch 1 taken 41532 times.
✓ Branch 2 taken 1839 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 416 times.
✓ Branch 5 taken 98 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
44531 switch(dmisc1)
1871 {
1872 case e1t5SHOTS: //BS-Aquamentus
1873 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+5)<<3),wdp,dir,-1, getUID(),false));
1874 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1875 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+5)<<3),wdp,dir,-1, getUID(),false));
1876 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1877
1878 [[fallthrough]];
1879 case e1t3SHOTSFAST:
1880 case e1t3SHOTS: //Aquamentus
1881
7/14
✓ Branch 0 taken 646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 646 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 646 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 646 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 646 times.
✗ Branch 13 not taken.
646 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1882 646 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1883
7/14
✓ Branch 0 taken 646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 646 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 646 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 646 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 646 times.
✗ Branch 13 not taken.
646 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1884 646 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1885
1886 [[fallthrough]];
1887 default:
1888
12/20
✓ Branch 0 taken 42178 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42178 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 42178 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 42178 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 42178 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 42173 times.
✓ Branch 12 taken 42178 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 18238 times.
✓ Branch 15 taken 23940 times.
✓ Branch 16 taken 42178 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 42178 times.
✗ Branch 19 not taken.
42178 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(dmisc1==e1t3SHOTSFAST || dmisc1==e1tFAST ? 4:0),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1889 42178 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1890 42178 sfx(wpnsfx(wpn),pan(x));
1891 42178 break;
1892
1893 case e1tSLANT:
1894 {
1895 416 int32_t slant = 0;
1896
1897
10/10
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 304 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 216 times.
✓ Branch 4 taken 47 times.
✓ Branch 5 taken 161 times.
✓ Branch 6 taken 61 times.
✓ Branch 7 taken 316 times.
✓ Branch 8 taken 138 times.
✓ Branch 9 taken 178 times.
416 if(((Hero.x-x) < -8 && dir==up) || ((Hero.x-x) > 8 && dir==down) || ((Hero.y-y) < -8 && dir==left) || ((Hero.y-y) > 8 && dir==right))
1898 246 slant = left;
1899
10/10
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 68 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 37 times.
✓ Branch 5 taken 33 times.
✓ Branch 6 taken 55 times.
✓ Branch 7 taken 86 times.
✓ Branch 8 taken 25 times.
✓ Branch 9 taken 61 times.
178 else if(((Hero.x-x) > 8 && dir==up) || ((Hero.x-x) < -8 && dir==down) || ((Hero.y-y) > 8 && dir==left) || ((Hero.y-y) < -8 && dir==right))
1900 117 slant = right;
1901
1902
9/18
✓ Branch 0 taken 330 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 330 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 330 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 330 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 330 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 330 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 330 times.
✓ Branch 14 taken 330 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 330 times.
✗ Branch 17 not taken.
330 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^slant)+1)<<3),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1903 330 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1904 330 sfx(wpnsfx(wpn),pan(x));
1905 330 break;
1906 }
1907
1908 case e1t8SHOTS: //Fire Wizzrobe
1909
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_up,-1, getUID(),false));
1910 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1911 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1912
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_down,-1, getUID(),false));
1913 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1914 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1915
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_up,-1, getUID(),false));
1916 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1917 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1918
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_down,-1, getUID(),false));
1919 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1920 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1921
1922 [[fallthrough]];
1923 case e1t4SHOTS: //Stalfos 3
1924
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,up,-1, getUID(),false));
1925 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1926 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1927
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,down,-1, getUID(),false));
1928 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1929 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1930
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,left,-1, getUID(),false));
1931 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1932 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1933
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,right,-1, getUID(),false));
1934 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1935 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1936 1937 sfx(wpnsfx(wpn),pan(x));
1937 1937 break;
1938
1939 case e1tSUMMON: // Bat Wizzrobe
1940 {
1941 if(dmisc4==0) break; // Summon 0
1942
1943 int32_t bc=0;
1944
1945 for(int32_t gc=0; gc<guys.Count(); gc++)
1946 {
1947 if((((enemy*)guys.spr(gc))->id) == dmisc3)
1948 {
1949 ++bc;
1950 }
1951 }
1952
1953 if(bc<=40) // Not too many enemies
1954 {
1955 int32_t kids = guys.Count();
1956 int32_t bats=(zc_oldrand()%zc_max(1,dmisc4))+1;
1957
1958 for(int32_t i=0; i<bats; i++)
1959 {
1960 if(addchild(screen_spawned,x,y,dmisc3,-10, this))
1961 {
1962 ((enemy*)guys.spr(kids+i))->count_enemy = false;
1963 }
1964 }
1965
1966 sfx(firesfx, pan(x));
1967 }
1968
1969 break;
1970 }
1971
1972 case e1tSUMMONLAYER: // Summoner
1973 {
1974 if(count_layer_enemies(screen_spawned)==0)
1975 {
1976 break;
1977 }
1978
1979 int32_t kids = guys.Count();
1980
1981 if(kids<40)
1982 {
1983 int32_t newguys=(zc_oldrand()%3)+1;
1984 bool summoned=false;
1985
1986 for(int32_t i=0; i<newguys; i++)
1987 {
1988 int32_t id2=vbound(random_layer_enemy(screen_spawned),eSTART,eMAXGUYS-1);
1989 int32_t x2=0;
1990 int32_t y2=0;
1991
1992 for(int32_t k=0; k<20; ++k)
1993 {
1994 x2=16*((zc_oldrand()%12)+2);
1995 y2=16*((zc_oldrand()%7)+2);
1996
1997 if((!m_walkflag(x2,y2,0,dir))&&((abs(x2-Hero.getX())>=32)||(abs(y2-Hero.getY())>=32)))
1998 {
1999 if(addchild_z(screen_spawned,x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this))
2000 {
2001 ((enemy*)guys.spr(kids+i))->count_enemy = false;
2002 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & move_use_fake_z))
2003 {
2004 ((enemy*)guys.spr(kids+i))->fakez = 64;
2005 ((enemy*)guys.spr(kids+i))->z = 0;
2006 }
2007 }
2008
2009 summoned=true;
2010 break;
2011 }
2012 }
2013 }
2014
2015 if(summoned)
2016 {
2017 sfx(firesfx, pan(x));
2018 }
2019 }
2020
2021 break;
2022 }
2023 }
2024 44576 }
2025
2026
2027 // Hit the shield(s)?
2028 // Apparently, this function is only used for hookshots...
2029 2767 bool enemy::hitshield(int32_t wpnx, int32_t wpny, int32_t xdir)
2030 {
2031
6/6
✓ Branch 0 taken 976 times.
✓ Branch 1 taken 1791 times.
✓ Branch 2 taken 975 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 141 times.
✓ Branch 5 taken 834 times.
2767 if(!(type==eeWALK || type==eeFIRE || type==eeOTHER))
2032 834 return false;
2033
2034 1933 bool ret = false;
2035
2036 // TODO: There must be some bitwise operations that can simplify this...
2037
9/12
✓ Branch 0 taken 1207 times.
✓ Branch 1 taken 726 times.
✓ Branch 2 taken 43 times.
✓ Branch 3 taken 683 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 16 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 699 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 699 times.
✓ Branch 10 taken 699 times.
✗ Branch 11 not taken.
1933 if(wpny > y) ret = ((flags&guy_shield_front && xdir==down) || (flags&guy_shield_back && xdir==up) || (flags&guy_shield_left && xdir==left) || (flags&guy_shield_right && xdir==right));
2038
9/12
✓ Branch 0 taken 383 times.
✓ Branch 1 taken 824 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 778 times.
✓ Branch 4 taken 33 times.
✓ Branch 5 taken 13 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 811 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 811 times.
✓ Branch 10 taken 811 times.
✗ Branch 11 not taken.
1207 else if(wpny < y) ret = ((flags&guy_shield_front && xdir==up) || (flags&guy_shield_back && xdir==down) || (flags&guy_shield_left && xdir==right) || (flags&guy_shield_right && xdir==left));
2039
2040
11/14
✓ Branch 0 taken 1065 times.
✓ Branch 1 taken 868 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 849 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 825 times.
✓ Branch 6 taken 9 times.
✓ Branch 7 taken 15 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 840 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 840 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 840 times.
1933 if(wpnx < x) ret = ret || ((flags&guy_shield_front && xdir==left) || (flags&guy_shield_back && xdir==right) || (flags&guy_shield_left && xdir==down) || (flags&guy_shield_right && xdir==up));
2041
11/14
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 876 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 863 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 827 times.
✓ Branch 6 taken 19 times.
✓ Branch 7 taken 17 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 844 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 844 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 844 times.
1065 else if(wpnx > x) ret = ret || ((flags&guy_shield_front && xdir==right) || (flags&guy_shield_back && xdir==left) || (flags&guy_shield_left && xdir==up) || (flags&guy_shield_right && xdir==down));
2042
2043 1933 return ret;
2044 2767 }
2045
2046
2047 //! Weapon Editor for 2.6
2048 //To hell with this. I'm writing new functions to resolve weapon type and defence. -Z
2049
2050
2051 //converts a wqeapon ID to its defence index.
2052 127485 int32_t weaponToDefence(int32_t wid)
2053 {
2054
23/47
✗ Branch 0 not taken.
✓ Branch 1 taken 64772 times.
✓ Branch 2 taken 9439 times.
✓ Branch 3 taken 25035 times.
✓ Branch 4 taken 4210 times.
✓ Branch 5 taken 37 times.
✓ Branch 6 taken 48 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3160 times.
✓ Branch 9 taken 9836 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 269 times.
✓ Branch 13 taken 1438 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 512 times.
✓ Branch 17 taken 1459 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 2054 times.
✓ Branch 20 taken 2767 times.
✓ Branch 21 taken 610 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 240 times.
✓ Branch 24 taken 469 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 19 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 28 times.
✗ Branch 31 not taken.
✓ Branch 32 taken 12 times.
✓ Branch 33 taken 77 times.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✓ Branch 39 taken 993 times.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✓ Branch 42 taken 1 times.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
127485 switch(wid)
2055 {
2056 case wNone: return -1;
2057 64772 case wSword: return edefSWORD;
2058 9439 case wBeam: return edefBEAM;
2059 25035 case wBrang: return edefBRANG;
2060 4210 case wBomb: return edefBOMB;
2061 37 case wSBomb: return edefSBOMB;
2062 48 case wLitBomb: return edefBOMB;
2063 case wLitSBomb: return edefSBOMB;
2064 3160 case wArrow: return edefARROW;
2065 9836 case wFire: return edefFIRE;
2066 case wWhistle:
2067 {
2068 return edefWhistle;
2069 }
2070 case wBait: return edefBAIT;
2071 269 case wWand: return edefWAND;
2072 1438 case wMagic: return edefMAGIC;
2073 case wCatching: return -1;
2074 case wWind: return edefWIND;
2075 512 case wRefMagic: return edefREFMAGIC;
2076 1459 case wRefFireball: return edefREFBALL;
2077 case wRefRock: return edefREFROCK;
2078 2054 case wHammer: return edefHAMMER;
2079 2767 case wHookshot: return edefHOOKSHOT;
2080 610 case wHSHandle: return edefHOOKSHOT;
2081 case wHSChain: return edefHOOKSHOT;
2082 240 case wSSparkle: return edefSPARKLE;
2083 469 case wFSparkle: return edefSPARKLE;
2084 case wSmack: return -1; // is this the candle object?
2085 case wPhantom: return -1; //engine created visual effects.
2086 case wCByrna: return edefBYRNA;
2087 19 case wRefBeam: return edefREFBEAM;
2088 case wStomp: return edefSTOMP;
2089 28 case wScript1: return edefSCRIPT01;
2090 case wScript2: return edefSCRIPT02;
2091 12 case wScript3: return edefSCRIPT03;
2092 77 case wScript4: return edefSCRIPT04;
2093 case wScript5: return edefSCRIPT05;
2094 case wScript6: return edefSCRIPT06;
2095 case wScript7: return edefSCRIPT07;
2096 case wScript8: return edefSCRIPT08;
2097 case wScript9: return edefSCRIPT09;
2098 993 case wScript10: return edefSCRIPT10;
2099 case wIce: return edefICE;
2100 case wSound: return edefSONIC;
2101 1 case wThrown: return edefTHROWN;
2102 case wRefArrow: return edefREFARROW;
2103 case wRefFire: return edefREFFIRE;
2104 case wRefFire2: return edefREFFIRE2;
2105 //case wPot: return edefPOT;
2106 // case wLitZap: return edefELECTRIC;
2107 // case wZ3Sword: return edefZ3SWORD;
2108 // case wLASWord: return edefLASWORD;
2109 // case wSpinAttk: return edefSPINATTK;
2110 // case wShield: return edefSHIELD;
2111 // case wTrowel: return edefTROWEL;
2112
2113 default: return -1;
2114 }
2115 127485 }
2116
2117 127485 int32_t getDefType(weapon *w)
2118 {
2119 127485 int32_t id = getWeaponID(w);
2120 127485 int32_t edef = weaponToDefence(id);
2121
2/2
✓ Branch 0 taken 124108 times.
✓ Branch 1 taken 3377 times.
127485 if(edef == edefHOOKSHOT)
2122 {
2123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3377 times.
3377 if(w->family_class == itype_switchhook)
2124 return edefSwitchHook;
2125 3377 }
2126 127485 return edef;
2127 127485 }
2128
2129 227168 int32_t getWeaponID(weapon *w)
2130 {
2131 227168 int32_t usewpn = w->useweapon;
2132
2/2
✓ Branch 0 taken 230 times.
✓ Branch 1 taken 226938 times.
227168 return (usewpn > 0) ? usewpn : w->id;
2133 }
2134
2135 127485 int32_t enemy::resolveEnemyDefence(weapon *w)
2136 {
2137 //sword edef is 9, but we're reading it at 0
2138 //,
2139 127485 int32_t weapondef = 0;
2140 127485 int32_t wdeftype = getDefType(w);
2141 127485 int32_t usedef = w->usedefense;
2142
2143
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 127485 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
127485 if ( usedef > 0 && (wdeftype < 0 || wdeftype >= edefLAST255 || defense[wdeftype] == 0))
2144 {
2145 weapondef = usedef*-1;
2146 }
2147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127485 times.
127485 else if(unsigned(wdeftype) < edefLAST255)
2148 {
2149 127485 weapondef = wdeftype;
2150 127485 }
2151 127485 return weapondef;
2152 }
2153
2154 138054 byte get_def_ignrflag(int32_t edef)
2155 {
2156
3/3
✓ Branch 0 taken 115084 times.
✓ Branch 1 taken 3683 times.
✓ Branch 2 taken 19287 times.
138054 switch(edef)
2157 {
2158 case edIGNORE:
2159 case edIGNOREL1:
2160 case edSTUNORIGNORE:
2161 19287 return WPNUNB_IGNR;
2162 case edSTUNORCHINK:
2163 case edCHINK:
2164 case edCHINKL1:
2165 case edCHINKL2:
2166 case edCHINKL4:
2167 case edCHINKL6:
2168 case edCHINKL8:
2169 case edCHINKL10:
2170 case edLEVELCHINK2:
2171 case edLEVELCHINK3:
2172 case edLEVELCHINK4:
2173 case edLEVELCHINK5:
2174 3683 return WPNUNB_BLOCK;
2175 }
2176 115084 return 0;
2177 138054 }
2178
2179 138054 int32_t conv_edef_unblockable(int32_t edef, byte unblockable)
2180 {
2181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138054 times.
138054 if(!(unblockable&get_def_ignrflag(edef))) return edef;
2182 switch(edef)
2183 {
2184 case edIGNORE:
2185 case edIGNOREL1:
2186 case edCHINK:
2187 case edCHINKL1:
2188 case edCHINKL2:
2189 case edCHINKL4:
2190 case edCHINKL6:
2191 case edCHINKL8:
2192 case edCHINKL10:
2193 case edLEVELCHINK2:
2194 case edLEVELCHINK3:
2195 case edLEVELCHINK4:
2196 case edLEVELCHINK5:
2197 return edNORMAL;
2198 case edSTUNORIGNORE:
2199 case edSTUNORCHINK:
2200 return edSTUNONLY;
2201 }
2202 return edef;
2203 138054 }
2204
2205 // Do we do damage?
2206 // 0: takehit returns 0
2207 // 1: takehit returns 1
2208 // -1: do damage
2209 //The input from resolveEnemyDefence() for the param 'edef' is negative if a specific defence RESULT is being used.
2210 126492 int32_t enemy::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable) //May need *wpn to set return on brangs and hookshots
2211 {
2212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126492 times.
126492 if(switch_hooked) return 0;
2213 126492 int32_t tempx = x;
2214 126492 int32_t tempy = y;
2215 126492 int32_t the_defence = 0;
2216
1/2
✓ Branch 0 taken 126492 times.
✗ Branch 1 not taken.
126492 if ( edef < 0 ) //we are using a specific base default defence for a weapon
2217 {
2218 the_defence = edef*-1; //A specific defence type.
2219 }
2220 126492 else the_defence = defense[edef];
2221
2222 126492 the_defence = conv_edef_unblockable(the_defence, unblockable);
2223
2224
3/4
✓ Branch 0 taken 6623 times.
✓ Branch 1 taken 119869 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6623 times.
126492 if(shieldCanBlock && !(unblockable&WPNUNB_SHLD))
2225 {
2226
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 6616 times.
✓ Branch 2 taken 7 times.
6623 switch(the_defence)
2227 {
2228 case edIGNORE:
2229 7 return 0;
2230 case edIGNOREL1:
2231 case edSTUNORIGNORE:
2232 if(*power <= 0)
2233 return 0;
2234 }
2235 6616 sfx(WAV_CHINK,pan(x));
2236 6616 return 1;
2237 }
2238
2239 119869 int32_t new_id = id;
2240 119869 int32_t effect_type = dmisc15;
2241 119869 int32_t delay_timer = 90;
2242 119869 enemy *gleeok = NULL;
2243 119869 enemy *ptra = NULL;
2244 119869 int32_t c = 0;
2245
2246
16/29
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 492 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1931 times.
✓ Branch 6 taken 1862 times.
✓ Branch 7 taken 113 times.
✓ Branch 8 taken 129 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 43 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 945 times.
✓ Branch 13 taken 17349 times.
✓ Branch 14 taken 883 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 2175 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 71 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 158 times.
✓ Branch 26 taken 105 times.
✓ Branch 27 taken 4 times.
✓ Branch 28 taken 93608 times.
119869 switch(the_defence)
2247 {
2248 case edREPLACE:
2249 {
2250 sclk = 0;
2251 if ( dmisc16 > 0 ) new_id = dmisc16;
2252 else new_id = id+1;
2253 if ( new_id > 511 ) new_id = id; //Sanity bound to legal enemy IDs.
2254 if ( dmisc17 > 0 ) delay_timer = dmisc17;
2255 //if ( dmisc18 > 0 ) dummy_wpn_id = dmisc18;
2256
2257 //Z_scripterrlog("new id is %d\n", new_id);
2258 switch(guysbuf[new_id&0xFFF].type)
2259 {
2260 //Fixme: possible enemy memory leak. (minor)
2261 case eeWALK:
2262 {
2263 enemy *e = new eStalfos(x,y,new_id,clk);
2264 guys.add(e);
2265 }
2266 break;
2267
2268 case eeLEV:
2269 {
2270 enemy *e = new eLeever(x,y,new_id,clk);
2271 guys.add(e);
2272 }
2273 break;
2274
2275 case eeTEK:
2276 {
2277 enemy *e = new eTektite(x,y,new_id,clk);
2278 guys.add(e);
2279 }
2280 break;
2281
2282 case eePEAHAT:
2283 {
2284 enemy *e = new ePeahat(x,y,new_id,clk);
2285 guys.add(e);
2286 }
2287 break;
2288
2289 case eeZORA:
2290 {
2291 enemy *e = new eZora(x,y,new_id,clk);
2292 guys.add(e);
2293 }
2294 break;
2295
2296 case eeGHINI:
2297 {
2298 enemy *e = new eGhini(x,y,new_id,clk);
2299 guys.add(e);
2300 }
2301 break;
2302
2303 case eeKEESE:
2304 {
2305 enemy *e = new eKeese(x,y,new_id,clk);
2306 guys.add(e);
2307 }
2308 break;
2309
2310 case eeWIZZ:
2311 {
2312 enemy *e = new eWizzrobe(x,y,new_id,clk);
2313 guys.add(e);
2314 }
2315 break;
2316
2317 case eePROJECTILE:
2318 {
2319 enemy *e = new eProjectile(x,y,new_id,clk);
2320 guys.add(e);
2321 }
2322 break;
2323
2324 case eeWALLM:
2325 {
2326 enemy *e = new eWallM(x,y,new_id,clk);
2327 guys.add(e);
2328 }
2329 break;
2330
2331 case eeAQUA:
2332 {
2333 enemy *e = new eAquamentus(x,y,new_id,clk);
2334 guys.add(e);
2335 e->x = x;
2336 e->y = y;
2337 }
2338 break;
2339
2340 case eeMOLD:
2341 {
2342 enemy *e = new eMoldorm(x,y,new_id,zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0])));
2343 guys.add(e);
2344 e->x = x;
2345 e->y = y;
2346 }
2347 break;
2348
2349 case eeMANHAN:
2350 {
2351 enemy *e = new eManhandla(x,y,new_id,clk);
2352 guys.add(e);
2353 e->x = x;
2354 e->y = y;
2355 }
2356 break;
2357
2358 case eeGLEEOK:
2359 {
2360 *power = 0;
2361 gleeok = new eGleeok(x,y,new_id,guysbuf[new_id&0xFFF].attributes[0]);
2362 guys.add(gleeok);
2363 // TODO(crash): check that .add succeeds.
2364 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2365 new_id &= 0xFFF;
2366 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0]));
2367 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2368 for(int32_t i=0; i<head_cnt; i++)
2369 {
2370 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2371 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2372 {
2373 al_trace("Gleeok head %d could not be created!\n",i+1);
2374
2375 for(int32_t j=0; j<i+1; j++)
2376 {
2377 guys.del(guys.Count()-1);
2378 }
2379
2380 break;
2381 }
2382 else
2383 {
2384 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2385 }
2386
2387 c-=guysbuf[new_id].attributes[3];
2388 }
2389 return 1;
2390 }
2391
2392 case eeGHOMA:
2393 {
2394 enemy *e = new eGohma(x,y,new_id,clk);
2395 guys.add(e);
2396 e->x = x;
2397 e->y = y;
2398 }
2399 break;
2400
2401 case eeLANM:
2402 {
2403 enemy *e = new eLanmola(x,y,new_id,zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].attributes[0])));
2404 guys.add(e);
2405 e->x = x;
2406 e->y = y;
2407 }
2408 break;
2409
2410 case eeGANON:
2411 {
2412 enemy *e = new eGanon(x,y,new_id,clk);
2413 guys.add(e);
2414 e->x = x;
2415 e->y = y;
2416 }
2417 break;
2418
2419 case eeFAIRY:
2420 {
2421 enemy *e = new eItemFairy(x,y,new_id+0x1000*clk,clk);
2422 guys.add(e);
2423 e->x = x;
2424 e->y = y;
2425 }
2426 break;
2427
2428 case eeFIRE:
2429 {
2430 enemy *e = new eFire(x,y,new_id,clk);
2431 guys.add(e);
2432 e->x = x;
2433 e->y = y;
2434 }
2435 break;
2436
2437 case eeOTHER:
2438 {
2439 enemy *e = new eOther(x,y,new_id,clk);
2440 guys.add(e);
2441 e->x = x;
2442 e->y = y;
2443 }
2444 break;
2445
2446 case eeSPINTILE:
2447 {
2448 enemy *e = new eSpinTile(x,y,new_id,clk);
2449 guys.add(e);
2450 e->x = x;
2451 e->y = y;
2452 }
2453 break;
2454
2455 // and these enemies use the misc10/misc2 value
2456 case eeROCK:
2457 {
2458 switch(guysbuf[new_id&0xFFF].attributes[9])
2459 {
2460 case 1:
2461 {
2462 enemy *e = new eBoulder(x,y,new_id,clk);
2463 guys.add(e);
2464 e->x = x;
2465 e->y = y;
2466 }
2467 break;
2468
2469 case 0:
2470 default:
2471 {
2472 enemy *e = new eRock(x,y,new_id,clk);
2473 guys.add(e);
2474 e->x = x;
2475 e->y = y;
2476 }
2477 break;
2478 }
2479
2480 break;
2481 }
2482
2483 case eeTRAP:
2484 {
2485 switch(guysbuf[new_id&0xFFF].attributes[1])
2486 {
2487 case 1:
2488 {
2489 enemy *e = new eTrap2(x,y,new_id,clk);
2490 guys.add(e);
2491 e->x = x;
2492 e->y = y;
2493 }
2494 break;
2495
2496 case 0:
2497 default:
2498 {
2499 enemy *e = new eTrap(x,y,new_id,clk);
2500 guys.add(e);
2501 e->x = x;
2502 e->y = y;
2503 }
2504 break;
2505 }
2506
2507 break;
2508 }
2509
2510 case eeDONGO:
2511 {
2512 switch(guysbuf[new_id&0xFFF].attributes[9])
2513 {
2514 case 1:
2515 {
2516 enemy *e = new eDodongo2(x,y,new_id,clk);
2517 guys.add(e);
2518 e->x = x;
2519 e->y = y;
2520 }
2521 break;
2522
2523 case 0:
2524 default:
2525 {
2526 enemy *e = new eDodongo(x,y,new_id,clk);
2527 guys.add(e);
2528 e->x = x;
2529 e->y = y;
2530 }
2531 break;
2532 }
2533
2534 break;
2535 }
2536
2537 case eeDIG:
2538 {
2539 switch(guysbuf[new_id&0xFFF].attributes[9])
2540 {
2541 case 1:
2542 {
2543 enemy *e = new eLilDig(x,y,new_id,clk);
2544 guys.add(e);
2545 e->x = x;
2546 e->y = y;
2547 }
2548 break;
2549
2550 case 0:
2551 default:
2552 {
2553 enemy *e = new eBigDig(x,y,new_id,clk);
2554 guys.add(e);
2555 e->x = x;
2556 e->y = y;
2557 }
2558 break;
2559 }
2560
2561 break;
2562 }
2563
2564 case eePATRA:
2565 {
2566 switch(guysbuf[new_id&0xFFF].attributes[9])
2567 {
2568 case 1:
2569 {
2570 if (get_qr(qr_HARDCODED_BS_PATRA))
2571 {
2572 enemy *e = new ePatraBS(x,y,new_id,clk);
2573 guys.add(e);
2574 e->x = x;
2575 e->y = y;
2576 break;
2577 }
2578 }
2579 [[fallthrough]];
2580 case 0:
2581 default:
2582 {
2583 enemy *e = new ePatra(x,y,new_id,clk);
2584 guys.add(e);
2585 e->x = x;
2586 e->y = y;
2587 }
2588 break;
2589 }
2590
2591 break;
2592 }
2593
2594 case eeGUY:
2595 {
2596 switch(guysbuf[new_id&0xFFF].attributes[9])
2597 {
2598 case 1:
2599 {
2600 enemy *e = new eTrigger(x,y,new_id,clk);
2601 guys.add(e);
2602 }
2603 break;
2604
2605 case 0:
2606 default:
2607 {
2608 enemy *e = new eNPC(x,y,new_id,clk);
2609 guys.add(e);
2610 }
2611 break;
2612 }
2613
2614 break;
2615 }
2616
2617 case eeSCRIPT01:
2618 case eeSCRIPT02:
2619 case eeSCRIPT03:
2620 case eeSCRIPT04:
2621 case eeSCRIPT05:
2622 case eeSCRIPT06:
2623 case eeSCRIPT07:
2624 case eeSCRIPT08:
2625 case eeSCRIPT09:
2626 case eeSCRIPT10:
2627 case eeSCRIPT11:
2628 case eeSCRIPT12:
2629 case eeSCRIPT13:
2630 case eeSCRIPT14:
2631 case eeSCRIPT15:
2632 case eeSCRIPT16:
2633 case eeSCRIPT17:
2634 case eeSCRIPT18:
2635 case eeSCRIPT19:
2636 case eeSCRIPT20:
2637 {
2638 enemy *e = new eScript(x,y,new_id,clk);
2639 guys.add(e);
2640 e->x = x;
2641 e->y = y;
2642 break;
2643 }
2644
2645
2646 case eeFFRIENDLY01:
2647 case eeFFRIENDLY02:
2648 case eeFFRIENDLY03:
2649 case eeFFRIENDLY04:
2650 case eeFFRIENDLY05:
2651 case eeFFRIENDLY06:
2652 case eeFFRIENDLY07:
2653 case eeFFRIENDLY08:
2654 case eeFFRIENDLY09:
2655 case eeFFRIENDLY10:
2656 {
2657 enemy *e = new eFriendly(x,y,new_id,clk);
2658 guys.add(e);
2659 e->x = x;
2660 e->y = y;
2661 break;
2662 }
2663
2664
2665 default: break;
2666 }
2667
2668 // add segments of segmented enemies
2669 int32_t c=0;
2670
2671 switch(guysbuf[new_id&0xFFF].type)
2672 {
2673 case eeMOLD:
2674 {
2675 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2676 new_id &= 0xFFF;
2677
2678 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[new_id].attributes[0])); i++)
2679 {
2680 //christ this is messy -DD
2681 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[new_id&0xFFF].step*100))));
2682
2683 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,new_id+0x1000,segclk)))
2684 {
2685 al_trace("Moldorm segment %d could not be created!\n",i+1);
2686
2687 for(int32_t j=0; j<i+1; j++)
2688 guys.del(guys.Count()-1);
2689
2690 return 0;
2691 }
2692
2693 if(i>0)
2694 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2695
2696
2697 }
2698
2699 break;
2700 }
2701
2702 case eeLANM:
2703 {
2704 new_id &= 0xFFF;
2705 int32_t shft = guysbuf[new_id].attributes[1];
2706 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2707 enemy *e = new esLanmola((zfix)x,(zfix)y,new_id+0x1000,0);
2708
2709 if(!guys.add(e))
2710 {
2711 al_trace("Lanmola segment 1 could not be created!\n");
2712 guys.del(guys.Count()-1);
2713 return 0;
2714 }
2715 e->x = x;
2716 e->y = y;
2717
2718
2719
2720 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].attributes[0])); i++)
2721 {
2722 enemy *e2 = new esLanmola((zfix)x,(zfix)y,new_id+0x2000,-(i<<shft));
2723 if(!guys.add(e2))
2724 {
2725 al_trace("Lanmola segment %d could not be created!\n",i+1);
2726
2727 for(int32_t j=0; j<i+1; j++)
2728 guys.del(guys.Count()-1);
2729
2730 return 0;
2731 }
2732 e2->x = x;
2733 e2->y = y;
2734
2735 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2736
2737 }
2738 }
2739 break;
2740
2741 case eeMANHAN:
2742 new_id &= 0xFFF;
2743
2744 for(int32_t i=0; i<((!(guysbuf[new_id].attributes[1]))?4:8); i++)
2745 {
2746 if(!guys.add(new esManhandla((zfix)x,(zfix)y,new_id+0x1000,i)))
2747 {
2748 al_trace("Manhandla head %d could not be created!\n",i+1);
2749
2750 for(int32_t j=0; j<i+1; j++)
2751 {
2752 guys.del(guys.Count()-1);
2753 }
2754
2755 return 0;
2756 }
2757
2758
2759 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[new_id].attributes[0];
2760 }
2761
2762 break;
2763
2764 case eeGLEEOK:
2765 {
2766 /*
2767 new_id &= 0xFFF;
2768 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0]));
2769 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2770 for(int32_t i=0; i<head_cnt; i++)
2771 {
2772 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2773 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2774 {
2775 al_trace("Gleeok head %d could not be created!\n",i+1);
2776
2777 for(int32_t j=0; j<i+1; j++)
2778 {
2779 guys.del(guys.Count()-1);
2780 }
2781
2782 break;
2783 }
2784
2785 c-=guysbuf[new_id].misc4;
2786 */
2787
2788 // }
2789 }
2790 break;
2791
2792
2793 case eePATRA:
2794 {
2795 new_id &= 0xFFF;
2796 int32_t outeyes = 0;
2797 ptra = new ePatraBS((zfix)x,(zfix)y,id,clk);
2798
2799 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].attributes[0]); i++)
2800 {
2801 if(!((guysbuf[new_id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,new_id+0x1000,i,ptra)):guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra))))
2802 {
2803 al_trace("Patra outer eye %d could not be created!\n",i+1);
2804
2805 for(int32_t j=0; j<i+1; j++)
2806 guys.del(guys.Count()-1);
2807
2808 return 0;
2809 }
2810 else
2811 outeyes++;
2812
2813
2814 }
2815
2816 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].attributes[1]); i++)
2817 {
2818 if(!guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra)))
2819 {
2820 al_trace("Patra inner eye %d could not be created!\n",i+1);
2821
2822 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
2823 guys.del(guys.Count()-1);
2824
2825 return 0;
2826 }
2827
2828
2829 }
2830 delete ptra;
2831 break;
2832 }
2833 }
2834
2835
2836 // TODO(crash): check that the above .add succeeded.
2837 ((enemy*)guys.spr(guys.Count()-1))->count_enemy = true;
2838 ((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
2839 ((enemy*)guys.spr(guys.Count()-1))->dir = this->dir;
2840 ((enemy*)guys.spr(guys.Count()-1))->scale = this->scale;
2841 ((enemy*)guys.spr(guys.Count()-1))->angular = this->angular;
2842 ((enemy*)guys.spr(guys.Count()-1))->angle = this->angle;
2843 ((enemy*)guys.spr(guys.Count()-1))->rotation = this->rotation;
2844 ((enemy*)guys.spr(guys.Count()-1))->itemguy = this->itemguy;
2845 ((enemy*)guys.spr(guys.Count()-1))->leader = this->leader;
2846 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2847 ((enemy*)guys.spr(guys.Count()-1))->script_spawned = this->script_spawned;
2848 ((enemy*)guys.spr(guys.Count()-1))->sclk = 0;
2849
2850
2851 item_set = 0; //Do not make a drop.
2852
2853 switch(effect_type)
2854 {
2855 case -7:
2856 {
2857 weapon *w = new weapon(x,y-fakez,z,wBomb,0,wdp,0,-1,getUID(),false, 0);
2858 Lwpns.add(w);
2859 break;
2860 }
2861 case -6:
2862 {
2863 weapon *w = new weapon(x,y-fakez,z,wSBomb,0,wdp,0,-1,getUID(),false, 0);
2864 Lwpns.add(w);
2865 break;
2866 }
2867 case -5:
2868 {
2869 weapon *w = new weapon(x,y-fakez,z,wBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2870 Lwpns.add(w);
2871 break;
2872 }
2873 case -4:
2874 {
2875 weapon *w = new weapon(x,y-fakez,z,wSBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2876 Lwpns.add(w);
2877 break;
2878 }
2879 case -3: explode(1); break;
2880 case -2: explode(2); break;
2881 case -1: explode(0); break;
2882 case 0: break;
2883
2884 default:
2885 {
2886 //Dummy weapon function
2887 if ( effect_type > 255 ) effect_type = 0; //Sanity bound the sprite ID.
2888 weapon *w = new weapon(x,y-fakez,z,wSSparkle,effect_type,0,0,Hero.getUID(), txsz, tysz,0,0,0,0,0,0,0);
2889 Lwpns.add(w);
2890 break;
2891 }
2892 }
2893
2894
2895 yofs = -32768;
2896 switch(guysbuf[new_id&0xFFF].type)
2897 {
2898 case eeGLEEOK:
2899 {
2900 Z_scripterrlog("Replacing a gleeok.\n");
2901 enemy *tempenemy = (enemy *) guys.getByUID(parentCore);
2902 hp = -999;
2903 if (tempenemy) tempenemy->hp = -999;
2904 break;
2905
2906 }
2907 default:
2908 hp = -1000; break;
2909 }
2910 int mi = mapind(cur_map, screen_spawned);
2911 ++game->guys[mi];
2912 return 1;
2913
2914 }
2915 case edSPLIT:
2916 {
2917 for ( int32_t q = 0; q < dmisc4; q++ )
2918 {
2919 addenemy(screen_spawned,x,y,
2920 dmisc3+0x1000,-15);
2921
2922 }
2923 item_set = 0; //Do not make a drop.
2924 hp = -1000;
2925 return -1;
2926
2927 }
2928 case edSUMMON:
2929 {
2930 int32_t summon_count = zc::math::SafeMod(zc_oldrand(), dmisc4) + 1;
2931 for ( int32_t q = 0; q < summon_count; q++ )
2932 {
2933 int32_t x2=16*((zc_oldrand()%12)+2);
2934 int32_t y2=16*((zc_oldrand()%7)+2);
2935 addenemy(screen_spawned,
2936 //(x+(txsz*16)/2),(y+(tysz*16)/2)
2937 x2,y2,
2938 dmisc3+0x1000,-15);
2939
2940 }
2941 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(x));
2942 return -1;
2943
2944 }
2945
2946 case edEXPLODESMALL:
2947 {
2948 weapon *ew=new weapon(x,y-fakez,z, ewBomb, 0, dmisc4, dir,-1,getUID(),false);
2949 Ewpns.add(ew);
2950 item_set = 0; //Should we make a drop?
2951 hp = -1000;
2952 return -1;
2953 }
2954
2955
2956 case edEXPLODEHARMLESS:
2957 {
2958 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
2959 Ewpns.add(ew);
2960 ew->hyofs = -32768;
2961 item_set = 0; //Should we make a drop?
2962 hp = -1000;
2963 return -1;
2964 }
2965
2966
2967 case edEXPLODELARGE:
2968 {
2969 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
2970 Ewpns.add(ew);
2971
2972 hp = -1000;
2973 return -1;
2974 }
2975
2976
2977 case edTRIGGERSECRETS:
2978 {
2979 trigger_secrets_for_screen(TriggerSource::Unspecified, screen_spawned, false);
2980 return -1;
2981 }
2982
2983 case edSTUNORCHINK:
2984
2/2
✓ Branch 0 taken 649 times.
✓ Branch 1 taken 1526 times.
2175 if(*power <= 0)
2985 {
2986 649 sfx(WAV_CHINK,pan(x));
2987 649 return 1;
2988 }
2989
2/2
✓ Branch 0 taken 407 times.
✓ Branch 1 taken 1119 times.
2645 if (stunclk)
2990 {
2991
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1119 times.
1119 if(get_qr(qr_NO_STUNLOCK_IGNORE))
2992 return 0;
2993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1119 times.
1119 if(get_qr(qr_NO_STUNLOCK_BLOCK))
2994 {
2995 sfx(WAV_CHINK,pan(x));
2996 return 1;
2997 }
2998 1119 }
2999 [[fallthrough]];
3000
3001 case edSTUNORIGNORE:
3002
2/2
✓ Branch 0 taken 955 times.
✓ Branch 1 taken 2502 times.
3457 if(*power <= 0)
3003 955 return 0;
3004
2/2
✓ Branch 0 taken 550 times.
✓ Branch 1 taken 1952 times.
4454 if (stunclk)
3005 {
3006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1952 times.
1952 if(get_qr(qr_NO_STUNLOCK_IGNORE))
3007 return 0;
3008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1952 times.
1952 if(get_qr(qr_NO_STUNLOCK_BLOCK))
3009 {
3010 sfx(WAV_CHINK,pan(x));
3011 return 1;
3012 }
3013 1952 }
3014 [[fallthrough]];
3015
3016 case edSTUNONLY:
3017
7/10
✓ Branch 0 taken 4364 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4364 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4364 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3817 times.
✓ Branch 7 taken 547 times.
✓ Branch 8 taken 4043 times.
✓ Branch 9 taken 321 times.
4364 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3018 {
3019 // Z_message("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId);
3020 321 return 1;
3021 }
3022
2/2
✓ Branch 0 taken 925 times.
✓ Branch 1 taken 3118 times.
4043 if (stunclk)
3023 {
3024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3118 times.
3118 if(get_qr(qr_NO_STUNLOCK_IGNORE))
3025 return 0;
3026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3118 times.
3118 if(get_qr(qr_NO_STUNLOCK_BLOCK))
3027 {
3028 sfx(WAV_CHINK,pan(x));
3029 return 1;
3030 }
3031 3118 }
3032 4043 stunclk=160;
3033 4043 sfx(WAV_EHIT,pan(x));
3034 4043 return 1;
3035
3036 case edCHINKL1:
3037 if(*power >= 1*game->get_hero_dmgmult()) break;
3038 [[fallthrough]];
3039 case edCHINKL2:
3040
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 61 times.
113 if(*power >= 2*game->get_hero_dmgmult()) break;
3041 [[fallthrough]];
3042 case edCHINKL4:
3043
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 110 times.
190 if(*power >= 4*game->get_hero_dmgmult()) break;
3044 [[fallthrough]];
3045 case edCHINKL6:
3046
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(*power >= 6*game->get_hero_dmgmult()) break;
3047 [[fallthrough]];
3048 case edCHINKL8:
3049
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 111 times.
154 if(*power >= 8*game->get_hero_dmgmult()) break;
3050 [[fallthrough]];
3051 case edCHINKL10:
3052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(*power >= 10*game->get_hero_dmgmult()) break;
3053 [[fallthrough]];
3054 case edCHINK:
3055 1056 sfx(WAV_CHINK,pan(x));
3056 1056 return 1;
3057
3058 case edIGNOREL1:
3059 if(*power > 0) break;
3060 [[fallthrough]];
3061
3062 case edIGNORE:
3063 17349 return 0;
3064
3065 case ed1HKO:
3066 492 *power = hp;
3067 492 return -3;
3068
3069 case ed2x:
3070 {
3071
1/2
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
71 *power = zc_max(1,*power*2);
3072 //int32_t pow = *power;
3073 //*power = vbound((pow*2),0,214747);
3074 71 return -1;
3075 }
3076 case ed3x:
3077 {
3078 *power = zc_max(1,*power*3);
3079 //int32_t pow = *power;
3080 //*power = vbound((pow*3),0,214747);
3081 return -1;
3082 }
3083
3084 case ed4x:
3085 {
3086 *power = zc_max(1,*power*4);
3087 //int32_t pow = *power;
3088 //*power = vbound((pow*4),0,214747);
3089 return -1;
3090 }
3091
3092
3093 case edHEAL:
3094 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3095 //int32_t pow = *power;
3096 //*power = vbound((pow*-1),0,214747);
3097 //break;
3098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158 times.
158 *power = zc_min(0,*power*-1);
3099 158 return -1;
3100 }
3101 /*
3102 case edLEVELDAMAGE:
3103 {
3104 int32_t pow = *power;
3105 int32_t lvl = *level;
3106 *power = vbound((pow*lvl),0,214747);
3107 break;
3108 }
3109 case edLEVELREDUCTION:
3110 {
3111 int32_t pow = *power;
3112 int32_t lvl = *level;
3113 *power = vbound((pow/lvl),0,214747);
3114 break;
3115 }
3116 */
3117
3118 case edQUARTDAMAGE:
3119
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 3 times.
105 *power = zc_max(1,*power/2);
3120
3121 [[fallthrough]];
3122 case edHALFDAMAGE:
3123
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 156 times.
988 *power = zc_max(1,*power/2);
3124 988 break;
3125
3126 case edSWITCH:
3127 {
3128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(Hero.switchhookclk) return 0; //Already switching!
3129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 switch(type)
3130 {
3131 case eeAQUA: case eeMOLD: case eeDONGO: case eeMANHAN: case eeGLEEOK:
3132 case eeDIG: case eeGHOMA: case eeLANM: case eePATRA: case eeGANON:
3133 return 0;
3134 }
3135 4 hooked_comborpos = rpos_t::None;
3136 4 hooked_layerbits = 0;
3137 4 switching_object = this;
3138 4 switch_hooked = true;
3139 4 Hero.doSwitchHook(game->get_switchhookstyle());
3140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(QMisc.miscsfx[sfxSWITCHED])
3141 sfx(QMisc.miscsfx[sfxSWITCHED],pan(x));
3142 4 return 1;
3143 }
3144
3145 case 0:
3146 {
3147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93608 times.
93608 if(edef == edefSwitchHook)
3148 return -1;
3149
4/4
✓ Branch 0 taken 19532 times.
✓ Branch 1 taken 74076 times.
✓ Branch 2 taken 7756 times.
✓ Branch 3 taken 11776 times.
93608 if (stunclk && *power == 0)
3150 {
3151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11776 times.
11776 if(get_qr(qr_NO_STUNLOCK_IGNORE))
3152 return 0;
3153
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 11750 times.
11776 if(get_qr(qr_NO_STUNLOCK_BLOCK))
3154 {
3155 26 sfx(WAV_CHINK,pan(x));
3156 26 return 1;
3157 }
3158 11750 }
3159 93582 break;
3160 }
3161 }
3162
3163 94745 return -1;
3164 126492 }
3165
3166 126492 int32_t enemy::defendNewInt(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable, weapon* w)
3167 {
3168
1/2
✓ Branch 0 taken 126492 times.
✗ Branch 1 not taken.
126492 int wuid = w?w->getUID():0;
3169
1/2
✓ Branch 0 taken 126492 times.
✗ Branch 1 not taken.
126492 bool fakeweap = (w && !Lwpns.getByUID(wuid));
3170
3171
1/2
✓ Branch 0 taken 126492 times.
✗ Branch 1 not taken.
126492 if(fakeweap)
3172 Lwpns.add(w);
3173 126492 std::vector<int32_t> &ev = FFCore.eventData;
3174 126492 ev.clear();
3175 126492 ev.push_back(*power*10000);
3176 126492 ev.push_back(edef*10000);
3177 126492 ev.push_back(unblockable*10000);
3178 126492 ev.push_back(wpnId*10000);
3179 126492 ev.push_back(0);
3180 126492 ev.push_back(getUID());
3181 126492 ev.push_back(wuid);
3182
3183 126492 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT1);
3184 126492 *power = ev[0]/10000;
3185 126492 edef = ev[1]/10000;
3186 126492 unblockable = byte(ev[2]/10000);
3187 126492 wpnId = ev[3] / 10000;
3188 126492 bool nullify = ev[4]!=0;
3189 126492 ev.clear();
3190 126492 int ret = 0;
3191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126492 times.
126492 if(!nullify)
3192 {
3193 126492 ret = defendNew(wpnId, power, edef, unblockable);
3194
2/2
✓ Branch 0 taken 32388 times.
✓ Branch 1 taken 94104 times.
126492 if(ret < 0)
3195 {
3196 94104 ev.push_back(*power*10000);
3197 94104 ev.push_back(edef*10000);
3198 94104 ev.push_back(unblockable*10000);
3199 94104 ev.push_back(wpnId*10000);
3200 94104 ev.push_back(0);
3201 94104 ev.push_back(getUID());
3202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94104 times.
94104 ev.push_back(w?w->getUID():0);
3203
3204 94104 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT2);
3205 94104 *power = ev[0]/10000;
3206 94104 nullify = ev[4]!=0;
3207 94104 ev.clear();
3208 94104 }
3209 126492 }
3210
1/2
✓ Branch 0 taken 126492 times.
✗ Branch 1 not taken.
126492 if(fakeweap)
3211 Lwpns.remove(w);
3212
3213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126492 times.
126492 return nullify ? 0 : ret;
3214 }
3215
3216 99683 int32_t enemy::defenditemclassNew(int32_t wpnId, int32_t *power, weapon *w, weapon* realweap)
3217 {
3218
2/2
✓ Branch 0 taken 99106 times.
✓ Branch 1 taken 577 times.
99683 if(!realweap) realweap = w;
3219 99683 int32_t wid = getWeaponID(w);
3220
3221 99683 int32_t edef = resolveEnemyDefence(w);
3222
2/2
✓ Branch 0 taken 6268 times.
✓ Branch 1 taken 93415 times.
99683 if(QHeader.zelda_version > 0x250)
3223 6268 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3224
2/3
✓ Branch 0 taken 993 times.
✓ Branch 1 taken 92422 times.
✗ Branch 2 not taken.
93415 switch(wid)
3225 {
3226 case wScript1: case wScript2: case wScript3: case wScript4: case wScript5:
3227 case wScript6: case wScript7: case wScript8: case wScript9: case wScript10:
3228 993 return defend(wpnId, power, edefSCRIPT);
3229
3230 case wWhistle:
3231 return -1;
3232
3233 default:
3234 92422 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3235 }
3236 99683 }
3237
3238
3239 // Check defenses without actually acting on them.
3240 27402 bool enemy::candamage(int32_t power, int32_t edef, byte unblockable)
3241 {
3242
4/10
✓ Branch 0 taken 15409 times.
✓ Branch 1 taken 11050 times.
✓ Branch 2 taken 469 times.
✓ Branch 3 taken 474 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
27402 switch(defense[edef])
3243 {
3244 case edSTUNONLY:
3245 474 return false;
3246 case edSTUNORCHINK:
3247 case edCHINK:
3248 15409 return unblockable&WPNUNB_BLOCK;
3249 case edSTUNORIGNORE:
3250 case edIGNORE:
3251 11050 return unblockable&WPNUNB_IGNR;
3252
3253 case edIGNOREL1:
3254 return (unblockable&WPNUNB_IGNR) || power >= 1*game->get_hero_dmgmult();
3255 case edCHINKL1:
3256 return (unblockable&WPNUNB_BLOCK) || power >= 1*game->get_hero_dmgmult();
3257
3258 case edCHINKL2:
3259 return (unblockable&WPNUNB_BLOCK) || power >= 2*game->get_hero_dmgmult();
3260
3261 case edCHINKL4:
3262 return (unblockable&WPNUNB_BLOCK) || power >= 4*game->get_hero_dmgmult();
3263
3264 case edCHINKL6:
3265 return (unblockable&WPNUNB_BLOCK) || power >= 6*game->get_hero_dmgmult();
3266
3267 case edCHINKL8:
3268 return (unblockable&WPNUNB_BLOCK) || power >= 8*game->get_hero_dmgmult();
3269 }
3270
3271 469 return true;
3272 27402 }
3273
3274 // Do we do damage?
3275 // 0: takehit returns 0
3276 // 1: takehit returns 1
3277 // -1: do damage
3278 993 int32_t enemy::defend(int32_t wpnId, int32_t *power, int32_t edef)
3279 {
3280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 993 times.
993 if(shieldCanBlock)
3281 {
3282 switch(defense[edef])
3283 {
3284 case edIGNORE:
3285 return 0;
3286 case edIGNOREL1:
3287 case edSTUNORIGNORE:
3288 if(*power <= 0)
3289 return 0;
3290 }
3291
3292 sfx(WAV_CHINK,pan(x));
3293 return 1;
3294 }
3295
3296
3/22
✓ Branch 0 taken 186 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 800 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 7 times.
993 switch(defense[edef])
3297 {
3298 case edSTUNORCHINK:
3299 if(*power <= 0)
3300 {
3301 sfx(WAV_CHINK,pan(x));
3302 return 1;
3303 }
3304
3305 [[fallthrough]];
3306 case edSTUNORIGNORE:
3307 if(*power <= 0)
3308 return 0;
3309
3310 [[fallthrough]];
3311 case edSTUNONLY:
3312 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3313 return 1;
3314
3315 stunclk=160;
3316 sfx(WAV_EHIT,pan(x));
3317 return 1;
3318
3319 case edFREEZE:
3320 frozenclock=-1;
3321 //sfx(WAV_FREEZE,pan(x));
3322 return 1;
3323
3324 case edCHINKL1:
3325 if(*power >= 1*game->get_hero_dmgmult()) break;
3326 [[fallthrough]];
3327 case edCHINKL2:
3328 if(*power >= 2*game->get_hero_dmgmult()) break;
3329 [[fallthrough]];
3330 case edCHINKL4:
3331 if(*power >= 4*game->get_hero_dmgmult()) break;
3332 [[fallthrough]];
3333 case edCHINKL6:
3334 if(*power >= 6*game->get_hero_dmgmult()) break;
3335 [[fallthrough]];
3336 case edCHINKL8:
3337 if(*power >= 8*game->get_hero_dmgmult()) break;
3338 [[fallthrough]];
3339 case edCHINKL10:
3340 if(*power >= 10*game->get_hero_dmgmult()) break;
3341 [[fallthrough]];
3342 case edCHINK:
3343 sfx(WAV_CHINK,pan(x));
3344 return 1;
3345 case edTRIGGERSECRETS:
3346 trigger_secrets_for_screen(TriggerSource::Unspecified, screen_spawned, false);
3347 break;
3348
3349 case edIGNOREL1:
3350 if(*power > 0) break;
3351 [[fallthrough]];
3352 case edIGNORE:
3353 800 return 0;
3354
3355 case ed1HKO:
3356 *power = hp;
3357 return -3;
3358
3359 case ed2x:
3360 {
3361 *power = zc_max(1,*power*2);
3362 //int32_t pow = *power;
3363 //*power = vbound((pow*2),0,214747);
3364 return -1;
3365 }
3366 case ed3x:
3367 {
3368 *power = zc_max(1,*power*3);
3369 //int32_t pow = *power;
3370 //*power = vbound((pow*3),0,214747);
3371 return -1;
3372 }
3373
3374 case ed4x:
3375 {
3376 *power = zc_max(1,*power*4);
3377 //int32_t pow = *power;
3378 //*power = vbound((pow*4),0,214747);
3379 return -1;
3380 }
3381
3382
3383 case edHEAL:
3384 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3385 //int32_t pow = *power;
3386 //*power = vbound((pow*-1),0,214747);
3387 //break;
3388 *power = zc_min(0,*power*-1);
3389 return -1;
3390 }
3391 /*
3392 case edLEVELDAMAGE:
3393 {
3394 int32_t pow = *power;
3395 int32_t lvl = *level;
3396 *power = vbound((pow*lvl),0,214747);
3397 break;
3398 }
3399 case edLEVELREDUCTION:
3400 {
3401 int32_t pow = *power;
3402 int32_t lvl = *level;
3403 *power = vbound((pow/lvl),0,214747);
3404 break;
3405 }
3406 */
3407
3408
3409 case edQUARTDAMAGE:
3410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3411
3412 [[fallthrough]];
3413 case edHALFDAMAGE:
3414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3415 7 break;
3416 }
3417
3418 193 return -1;
3419 993 }
3420
3421 // Defend against a particular item class.
3422 int32_t enemy::defenditemclass(int32_t wpnId, int32_t *power)
3423 {
3424 int32_t def=-1;
3425
3426 switch(wpnId)
3427 {
3428 // These first 2 are only used by Gohma... enemy::takehit() has complicated stun-calculation code for these.
3429 case wBrang:
3430 def = defend(wpnId, power, edefBRANG);
3431 break;
3432
3433 case wHookshot:
3434 def = defend(wpnId, power, edefHOOKSHOT);
3435 break;
3436
3437 // Anyway...
3438 case wBomb:
3439 def = defend(wpnId, power, edefBOMB);
3440 break;
3441
3442 case wSBomb:
3443 def = defend(wpnId, power, edefSBOMB);
3444 break;
3445
3446 case wArrow:
3447 def = defend(wpnId, power, edefARROW);
3448 break;
3449
3450 case wFire:
3451 def = defend(wpnId, power, edefFIRE);
3452 break;
3453
3454 case wWand:
3455 def = defend(wpnId, power, edefWAND);
3456 break;
3457
3458 case wMagic:
3459 def = defend(wpnId, power, edefMAGIC);
3460 break;
3461
3462 case wHammer:
3463 def = defend(wpnId, power, edefHAMMER);
3464 break;
3465
3466 case wSword:
3467 def = defend(wpnId, power, edefSWORD);
3468 break;
3469
3470 case wBeam:
3471 def = defend(wpnId, power, edefBEAM);
3472 break;
3473
3474 case wRefBeam:
3475 def = defend(wpnId, power, edefREFBEAM);
3476 break;
3477
3478 case wRefMagic:
3479 def = defend(wpnId, power, edefREFMAGIC);
3480 break;
3481
3482 case wRefFireball:
3483 def = defend(wpnId, power, edefREFBALL);
3484 break;
3485
3486 case wRefRock:
3487 def = defend(wpnId, power, edefREFROCK);
3488 break;
3489
3490 case wStomp:
3491 def = defend(wpnId, power, edefSTOMP);
3492 break;
3493
3494 case wCByrna:
3495 def = defend(wpnId, power, edefBYRNA);
3496 break;
3497
3498 case wScript1:
3499 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT01);
3500 else def = defend(wpnId, power, edefSCRIPT);
3501 break;
3502
3503 case wScript2:
3504 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT02);
3505 else def = defend(wpnId, power, edefSCRIPT);
3506 break;
3507
3508 case wScript3:
3509 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT03);
3510 else def = defend(wpnId, power, edefSCRIPT);
3511 break;
3512
3513 case wScript4:
3514 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT04);
3515 else def = defend(wpnId, power, edefSCRIPT);
3516 break;
3517
3518 case wScript5:
3519 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT05);
3520 else def = defend(wpnId, power, edefSCRIPT);
3521 break;
3522
3523 case wScript6:
3524 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT06);
3525 else def = defend(wpnId, power, edefSCRIPT);
3526 break;
3527
3528 case wScript7:
3529 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT07);
3530 else def = defend(wpnId, power, edefSCRIPT);
3531 break;
3532
3533 case wScript8:
3534 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT08);
3535 else def = defend(wpnId, power, edefSCRIPT);
3536 break;
3537
3538 case wScript9:
3539 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT09);
3540 else def = defend(wpnId, power, edefSCRIPT);
3541 break;
3542
3543 case wScript10:
3544 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT10);
3545 else def = defend(wpnId, power, edefSCRIPT);
3546 break;
3547
3548 case wWhistle:
3549 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefWhistle);
3550 else break;
3551 break;
3552
3553 case wRefArrow:
3554 def = defend(wpnId, power, edefREFARROW);
3555 break;
3556 case wRefFire:
3557 def = defend(wpnId, power, edefREFFIRE);
3558 break;
3559 case wRefFire2:
3560 def = defend(wpnId, power, edefREFFIRE2);
3561 break;
3562
3563 //!ZoriaRPG : We need some special cases here, to ensure that old script defs don;t break.
3564 //Probably best to do this from the qest file, loading the values of Script(generic) into each
3565 //of the ten if the quest version is lower than N.
3566 //Either that, or we need a boolean flag to set int32_t he enemy editor, or by ZScript that changes this behaviour.
3567 //such as bool UseSeparatedScriptDefences. hah.
3568 default:
3569 //if(wpnId>=wScript1 && wpnId<=wScript10)
3570 // {
3571 // def = defend(wpnId, power, edefSCRIPT);
3572 // }
3573 // }
3574
3575 break;
3576 }
3577
3578 return def;
3579 }
3580
3581 // take damage or ignore it
3582 // 2 or -2: force wait a frame
3583 // < 0: damage (if any) dealt
3584 // > 0: blocked
3585 // 0: weapon passes through unhindered
3586 265281 int32_t enemy::takehit(weapon *w, weapon* realweap)
3587 {
3588
2/4
✓ Branch 0 taken 265281 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 265281 times.
265281 if(fallclk||drownclk) return 0;
3589
2/2
✓ Branch 0 taken 69774 times.
✓ Branch 1 taken 195507 times.
265281 if(!realweap) realweap = w;
3590 265281 int32_t wpnId = w->id;
3591 265281 int32_t power = w->power;
3592 265281 int32_t wpnx = w->x;
3593 265281 int32_t wpny = w->y;
3594 265281 int32_t enemyHitWeapon = w->parentitem;
3595 int32_t wpnDir;
3596 265281 int32_t parent_item = w->parentitem;
3597
3598
2/2
✓ Branch 0 taken 265166 times.
✓ Branch 1 taken 115 times.
265281 if ( w->useweapon > 0 /*&& wpnId != wWhistle*/ )
3599 {
3600 115 wpnId = w->useweapon;
3601 115 }
3602
3603 // If it's a boomerang that just bounced, use the opposite direction;
3604 // otherwise, it might bypass a shield. This probably won't handle
3605 // every case correctly, but it's better than having shields simply
3606 // not work against boomerangs.
3607
8/8
✓ Branch 0 taken 25081 times.
✓ Branch 1 taken 240200 times.
✓ Branch 2 taken 15580 times.
✓ Branch 3 taken 9501 times.
✓ Branch 4 taken 14362 times.
✓ Branch 5 taken 1218 times.
✓ Branch 6 taken 3306 times.
✓ Branch 7 taken 11056 times.
265281 if(w->id==wBrang && w->misc==1 && w->clk2>=256 && w->clk2<264)
3608 11056 wpnDir = oppositeDir[w->dir];
3609 else
3610 254225 wpnDir = w->dir;
3611
3612
5/8
✓ Branch 0 taken 265281 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 265281 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 265281 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8040 times.
✓ Branch 7 taken 272607 times.
265281 if(dying || clk<0 || hclk>0 || superman)
3613 8040 return 0;
3614
3615 //Prevent boomerang from writing to hitby[] for more than one frame.
3616 //This also prevents stunlock.
3617 //if ( stunclk > 0 ) return 0;
3618 //this needs a rule for boomerangs that cannot stunlock!
3619 //further, bouncing weapons should probably SFX_CHINK and bounce here.
3620 //sigh.
3621
3622 272607 int32_t ret = -1;
3623
3624 // This obscure quest rule...
3625
5/6
✓ Branch 0 taken 92333 times.
✓ Branch 1 taken 180274 times.
✓ Branch 2 taken 88830 times.
✓ Branch 3 taken 3503 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 88830 times.
272607 if(get_qr(qr_BOMBDARKNUTFIX) && (wpnId==wBomb || wpnId==wSBomb))
3626 {
3627 double _MSVC2022_tmp1, _MSVC2022_tmp2;
3628 3503 double ddir=atan2_MSVC2022_FIX(double(wpny-y),double(x-wpnx));
3629 3503 wpnDir=zc_oldrand()&3;
3630
3631
4/4
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 3036 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 189 times.
3503 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
3632 {
3633 189 wpnDir=down;
3634 189 }
3635
4/4
✓ Branch 0 taken 563 times.
✓ Branch 1 taken 2751 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 285 times.
3314 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
3636 {
3637 285 wpnDir=right;
3638 285 }
3639
4/4
✓ Branch 0 taken 2342 times.
✓ Branch 1 taken 687 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 2064 times.
3029 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
3640 {
3641 2064 wpnDir=up;
3642 2064 }
3643 else
3644 {
3645 965 wpnDir=left;
3646 }
3647 3503 }
3648
3649 272607 int32_t xdir = dir;
3650 272607 shieldCanBlock=false;
3651
3652
4/4
✓ Branch 0 taken 261327 times.
✓ Branch 1 taken 11280 times.
✓ Branch 2 taken 2767 times.
✓ Branch 3 taken 258560 times.
273369 if(!(w->unblockable&WPNUNB_BLOCK)&&((wpnId==wHookshot && hitshield(wpnx, wpny, xdir))
3653
6/6
✓ Branch 0 taken 18380 times.
✓ Branch 1 taken 15613 times.
✓ Branch 2 taken 26253 times.
✓ Branch 3 taken 247920 times.
✓ Branch 4 taken 108 times.
✓ Branch 5 taken 247812 times.
261327 || ((flags&guy_shield_front && wpnDir==(xdir^down)) || (flags&guy_shield_back && wpnDir==(xdir^up)) ||
3654
4/4
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 246793 times.
✓ Branch 2 taken 762 times.
✓ Branch 3 taken 246031 times.
247812 (flags&guy_shield_left && wpnDir==(xdir^(xdir&2?right:left))) || (flags&guy_shield_right && wpnDir==(xdir^(dir&2?left:right)))))
3655 )
3656 // The hammer should already be dealt with by subclasses (Walker etc.)
3657 {
3658
10/10
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 380 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 680 times.
✓ Branch 4 taken 5804 times.
✓ Branch 5 taken 338 times.
✓ Branch 6 taken 14 times.
✓ Branch 7 taken 11 times.
✓ Branch 8 taken 153 times.
✓ Branch 9 taken 1488 times.
46522 switch(wpnId)
3659 {
3660 // Weapons which shields protect against
3661 case wSword:
3662 case wWand:
3663
2/2
✓ Branch 0 taken 5802 times.
✓ Branch 1 taken 2 times.
5806 if(Hero.getCharging()>0)
3664 2 Hero.setAttackClk(Hero.getAttackClk()+1); //Cancel charging
3665
3666 [[fallthrough]];
3667 case wHookshot:
3668 case wHSHandle:
3669 case wBrang:
3670 6184 shieldCanBlock=true;
3671 6522 break;
3672
3673 case wBeam:
3674 case wRefBeam:
3675 // Mirror shielded enemies!
3676 #if 0
3677 if(false /*flags&guy_mirror*/ && !get_qr(qr_SWORDMIRROR))
3678 {
3679 if(wpnId>wEnemyWeapons)
3680 return 0;
3681
3682 sfx(WAV_CHINK,pan(x));
3683 return 1;
3684 }
3685
3686 #endif
3687
3688 [[fallthrough]];
3689 case wRefRock:
3690 case wRefFireball:
3691 case wMagic:
3692 #if 0
3693 if(false /*flags&guy_mirror*/ && (wpnId!=wRefRock || get_qr(qr_REFLECTROCKS)))
3694 {
3695 sfx(WAV_CHINK,pan(x));
3696 return 3;
3697 }
3698
3699 #endif
3700
3701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 368 times.
368 if(wpnId>wEnemyWeapons)
3702 return 0;
3703
3704 [[fallthrough]];
3705 case wArrow:
3706 382 case wRefArrow:
3707 default:
3708 1870 shieldCanBlock=true;
3709 1870 break;
3710
3711 // Bombs
3712 case wSBomb:
3713 case wBomb:
3714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if (!get_qr(qr_TRUEFIXEDBOMBSHIELD)) goto hitclock;
3715 else if (!get_qr(qr_BOMBSPIERCESHIELD))
3716 {
3717 sfx(WAV_CHINK,pan(x));
3718 return 0;
3719 }
3720 else break;
3721
3722 // Weapons which ignore shields
3723 case wWhistle:
3724 case wHammer:
3725 153 break;
3726
3727 // Weapons which shouldn't be removed by shields
3728 case wLitBomb:
3729 case wLitSBomb:
3730 case wWind:
3731 case wPhantom:
3732 case wSSparkle:
3733 case wBait:
3734 864 return 0;
3735
3736 case wFire:
3737 case wRefFire:
3738 case wRefFire2:
3739 ;
3740 680 }
3741 8887 }
3742
3743
8/8
✓ Branch 0 taken 103219 times.
✓ Branch 1 taken 98026 times.
✓ Branch 2 taken 423 times.
✓ Branch 3 taken 270 times.
✓ Branch 4 taken 27402 times.
✓ Branch 5 taken 25035 times.
✓ Branch 6 taken 2767 times.
✓ Branch 7 taken 9056 times.
266198 switch(wpnId)
3744 {
3745 case wWhistle: //No longer completely ignore whistle weapons! -Z
3746 {
3747
3748
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 423 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
423 if ( ((itemsbuf[parent_item].flags & item_flag2) == 0) || ( parent_item == -1 ) ) //if the flag is set, or the weapon is scripted
3749 {
3750 423 return 0; break;
3751 }
3752 else
3753 {
3754 w->power = power = itemsbuf[parent_item].misc5;
3755
3756 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3757
3758 if(def <= 0)
3759 {
3760 hp -= power;
3761 return def;
3762 }
3763 break;
3764 }
3765 break;
3766 }
3767
3768 case wPhantom:
3769 270 return 0;
3770
3771 case wLitBomb:
3772 case wLitSBomb:
3773 case wBait:
3774 case wWind:
3775 case wSSparkle:
3776 103219 return 0;
3777
3778 case wFSparkle:
3779
3780 // Only take sparkle damage if the sparkle's parent item is not
3781 // defended against.
3782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27402 times.
27402 if(enemyHitWeapon > -1)
3783 {
3784 27402 int32_t p = 0;
3785 27402 int32_t f = itemsbuf[enemyHitWeapon].type;
3786
3787
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27402 times.
27402 switch(f)
3788 {
3789 case itype_arrow:
3790 if(!candamage(p, edefARROW, w->unblockable)) return 0;
3791
3792 break;
3793
3794 case itype_cbyrna:
3795 if(!candamage(p, edefBYRNA, w->unblockable)) return 0;
3796
3797 break;
3798
3799 case itype_brang:
3800
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 26933 times.
27402 if(!candamage(p, edefBRANG, w->unblockable)) return 0;
3801
3802 469 break;
3803
3804 default:
3805 return 0;
3806 }
3807 469 }
3808
3809 469 wpnId = wSword;
3810 469 power = game->get_hero_dmgmult()>>1;
3811 469 goto fsparkle;
3812 break;
3813
3814 case wBrang:
3815 {
3816 //int32_t def = defendNew(wpnId, &power, edefBRANG, w);
3817 25035 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3818 //preventing stunlock might be best, here. -Z
3819
2/2
✓ Branch 0 taken 5471 times.
✓ Branch 1 taken 19564 times.
25035 if(def >= 0) return def;
3820 19564 ret = def;
3821
3822 // Not hurt by 0-damage weapons
3823
2/2
✓ Branch 0 taken 3184 times.
✓ Branch 1 taken 16380 times.
19564 if(!(flags & guy_bhit))
3824 {
3825 16380 stunclk=160;
3826
3827
3/4
✓ Branch 0 taken 16380 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1311 times.
✓ Branch 3 taken 15069 times.
16380 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))
3828 {
3829
1/2
✓ Branch 0 taken 1311 times.
✗ Branch 1 not taken.
1311 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))*game->get_hero_dmgmult();
3830 1311 goto hitclock;
3831 }
3832
3833 15069 break;
3834 }
3835
3836
2/2
✓ Branch 0 taken 391 times.
✓ Branch 1 taken 2793 times.
3184 if(!power)
3837
1/2
✓ Branch 0 taken 2793 times.
✗ Branch 1 not taken.
2793 hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].level : current_item(itype_brang))*game->get_hero_dmgmult();
3838 else
3839 391 hp-=power;
3840
3841 3184 goto hitclock;
3842 }
3843
3844 case wHookshot:
3845 {
3846 //int32_t def = defendNew(wpnId, &power, edefHOOKSHOT,w);
3847 2767 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3848
3849
2/2
✓ Branch 0 taken 994 times.
✓ Branch 1 taken 1773 times.
2767 if(def >= 0) return def;
3850 1773 ret = def;
3851
3852
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1773 times.
1773 bool swgrab = switch_hooked || w->family_class == itype_switchhook;
3853
3/4
✓ Branch 0 taken 1773 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1625 times.
✓ Branch 3 taken 148 times.
1773 if(swgrab || !(flags & guy_bhit))
3854 {
3855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1625 times.
1625 if(!swgrab)
3856 1625 stunclk=160;
3857
3858
3/4
✓ Branch 0 taken 1625 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 549 times.
✓ Branch 3 taken 1076 times.
1625 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))
3859 {
3860
1/2
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
549 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))*game->get_hero_dmgmult();
3861 549 goto hitclock;
3862 }
3863
3864 1076 break;
3865 }
3866
3867
3/4
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 103 times.
✓ Branch 2 taken 103 times.
✗ Branch 3 not taken.
148 if(!power) hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].level : current_item(itype_hookshot))*game->get_hero_dmgmult();
3868 else
3869 45 hp-=power;
3870
3871 148 goto hitclock;
3872 }
3873 break;
3874
3875 case wHSHandle:
3876 {
3877
3/4
✓ Branch 0 taken 9056 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 523 times.
✓ Branch 3 taken 8533 times.
9056 if(itemsbuf[enemyHitWeapon>-1 ? enemyHitWeapon : current_item_id(itype_hookshot)].flags & item_flag1)
3878 523 return 0;
3879
3880
3/4
✓ Branch 0 taken 6093 times.
✓ Branch 1 taken 2440 times.
✓ Branch 2 taken 2440 times.
✗ Branch 3 not taken.
8533 bool ignorehookshot = ((defense[edefHOOKSHOT] == edIGNORE) || ((defense[edefHOOKSHOT] == edIGNOREL1 || defense[edefHOOKSHOT] == edSTUNORIGNORE)
3881
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2440 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2440 && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot)) <= 0));
3882
3883 // Peahats, Darknuts, Aquamentuses, Pols Voices, Wizzrobes, Manhandlas
3884
6/8
✓ Branch 0 taken 2787 times.
✓ Branch 1 taken 5746 times.
✓ Branch 2 taken 2787 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2787 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 502 times.
✓ Branch 7 taken 2285 times.
10245 if(!(type==eePEAHAT || type==eeAQUA || type==eeMANHAN || (type==eeWIZZ && !ignorehookshot)
3885
6/6
✓ Branch 0 taken 3375 times.
✓ Branch 1 taken 2873 times.
✓ Branch 2 taken 1771 times.
✓ Branch 3 taken 3889 times.
✓ Branch 4 taken 1712 times.
✓ Branch 5 taken 2177 times.
2787 || (type==eeWALK && dmisc9==e9tPOLSVOICE) || (type==eeWALK && flags&(guy_shield_back|guy_shield_front|guy_shield_left|guy_shield_right))))
3886 2177 return 0;
3887
3888 12102 power = game->get_hero_dmgmult();
3889 12571 }
3890
3891 fsparkle:
3892
3893 [[fallthrough]];
3894 default:
3895 // Work out the defenses!
3896 {
3897 99105 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
3898
3899
2/2
✓ Branch 0 taken 26566 times.
✓ Branch 1 taken 72539 times.
99105 if(def >= 0)
3900 26566 return def;
3901
2/2
✓ Branch 0 taken 72079 times.
✓ Branch 1 taken 460 times.
72539 else if(def == -3) // OHKO... doesn't 'hit' the weapon?
3902 460 ret = 0;
3903 }
3904
3905
2/2
✓ Branch 0 taken 72537 times.
✓ Branch 1 taken 2 times.
145078 if(!power)
3906 {
3907
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(flags & guy_bhit)
3908 2 hp-=1;
3909 else
3910 {
3911 // Don't make a long chain of 'stun' hits
3912 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wSword) && stunclk>0)
3913 return 1;
3914
3915
3916 if(!switch_hooked)
3917 stunclk=160;
3918 break;
3919 }
3920 2 }
3921 72537 else hp-=power;
3922
3923 hitclock:
3924 77742 hclk=33;
3925
3926 // Use w->dir instead of wpnDir to make sure boomerangs don't push enemies the wrong way
3927
2/2
✓ Branch 0 taken 34732 times.
✓ Branch 1 taken 43010 times.
77742 if((dir&2)==(w->dir&2))
3928 {
3929 43010 sclk=(w->dir<<8)+16;
3930 43010 }
3931 77742 }
3932
3933
5/6
✓ Branch 0 taken 74323 times.
✓ Branch 1 taken 19564 times.
✓ Branch 2 taken 21982 times.
✓ Branch 3 taken 71905 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21982 times.
93887 if(((wpnId==wBrang) || (get_qr(qr_NOFLASHDEATH))) && (hp<=0 && !immortal))
3934 {
3935 21982 fading=fade_blue_poof;
3936 21982 }
3937
3938
6/6
✓ Branch 0 taken 88602 times.
✓ Branch 1 taken 5285 times.
✓ Branch 2 taken 46937 times.
✓ Branch 3 taken 41665 times.
✓ Branch 4 taken 2347 times.
✓ Branch 5 taken 44590 times.
93887 if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 )) //2.53 Gamma 2 and later
3939 {
3940
1/2
✓ Branch 0 taken 7632 times.
✗ Branch 1 not taken.
7632 if( hitsfx > 0 ) //user-set hit sound.
3941 {
3942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7632 times.
7632 if (!dying) //don't play the hit sound on death! -Z
3943 7632 sfx(hitsfx, pan(x));
3944 7632 }
3945 else sfx(WAV_EHIT, pan(x)); //Don't play the hardcoded sound if the user sets a custom one.
3946 7632 }
3947 else //2.50.2 or earlier
3948 {
3949 86255 sfx(WAV_EHIT, pan(x));
3950 86255 sfx(hitsfx, pan(x));
3951 }
3952
2/2
✓ Branch 0 taken 93858 times.
✓ Branch 1 taken 29 times.
93887 if(type==eeGUY)
3953 29 sfx(WAV_EDEAD, pan(x));
3954
3955 // Penetrating weapons
3956
4/4
✓ Branch 0 taken 92013 times.
✓ Branch 1 taken 1874 times.
✓ Branch 2 taken 85107 times.
✓ Branch 3 taken 8780 times.
93887 if((wpnId==wArrow || wpnId==wBeam) && !cannotpenetrate())
3957 {
3958 8780 int32_t item=enemyHitWeapon;
3959
3960
2/2
✓ Branch 0 taken 1612 times.
✓ Branch 1 taken 7168 times.
8780 if(wpnId==wArrow)
3961 {
3962 //If we use an arrow type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3963
5/6
✓ Branch 0 taken 1484 times.
✓ Branch 1 taken 128 times.
✓ Branch 2 taken 379 times.
✓ Branch 3 taken 1105 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 379 times.
1612 if(item>=0 && (itemsbuf[item].flags&item_flag1) && (itemsbuf[parent_item].type == itype_arrow))
3964 379 return 0;
3965
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1233 times.
1233 else if(get_qr(qr_ARROWS_ALWAYS_PENETRATE)) return 0;
3966 //if(item<0)
3967 else
3968 1233 item=current_item_id(itype_arrow);
3969 1233 }
3970
3971 else
3972 {
3973
3974 //If we use an swordbeam type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3975
3/6
✓ Branch 0 taken 7150 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7150 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7168 if(item>=0 && (itemsbuf[item].flags&item_flag3) && (itemsbuf[parent_item].type == itype_sword))
3976 return 0;
3977
3978
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7168 times.
7168 else if(get_qr(qr_SWORDBEAMS_ALWAYS_PENETRATE)) return 0;
3979 else
3980 //if(item<0)
3981 7168 item=current_item_id(itype_sword);
3982 }
3983 8401 }
3984
3985 93508 return ret;
3986 269367 }
3987
3988 61890611 bool enemy::dont_draw()
3989 {
3990
6/6
✓ Branch 0 taken 61426098 times.
✓ Branch 1 taken 464513 times.
✓ Branch 2 taken 61355191 times.
✓ Branch 3 taken 70907 times.
✓ Branch 4 taken 175008 times.
✓ Branch 5 taken 61251090 times.
61890611 if(fading==fade_invisible || (((flags&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
3991 639521 return true;
3992
3993
2/2
✓ Branch 0 taken 1371825 times.
✓ Branch 1 taken 59879265 times.
61251090 if(flags&guy_invisible)
3994 1371825 return true;
3995
3996
3/4
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 59878833 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 432 times.
59879265 if(flags&guy_lens_only && !lensclk)
3997 return true;
3998
3999 59879265 return false;
4000 61890611 }
4001
4002 #define DRAW_NORMAL 2
4003 #define DRAW_CLOAKED 1
4004 #define DRAW_INVIS 0
4005 // base drawing function to be used by all derived classes instead of
4006 // sprite::draw()
4007 44971115 void enemy::draw(BITMAP *dest)
4008 {
4009 44971115 didScriptThisFrame = false; //Since there's no better place to put it
4010
6/6
✓ Branch 0 taken 44205983 times.
✓ Branch 1 taken 765132 times.
✓ Branch 2 taken 44123333 times.
✓ Branch 3 taken 82650 times.
✓ Branch 4 taken 317531 times.
✓ Branch 5 taken 43888452 times.
44971115 if(fading==fade_invisible || (((flags&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
4011 1082663 return;
4012
2/2
✓ Branch 0 taken 2767665 times.
✓ Branch 1 taken 41120787 times.
43888452 if(flags&guy_invisible)
4013 2767665 return;
4014
4015 //We did the normal don't_draw stuff here so we can make exceptions; specifically the lens check (which should make enemies
4016 // be cloaked if they have "invisible displays as cloaked" checked.
4017
4018 41120787 byte canSee = DRAW_NORMAL;
4019 //Enemy specific stuff
4020
2/2
✓ Branch 0 taken 41119623 times.
✓ Branch 1 taken 1164 times.
41120787 if ( editorflags & ENEMY_FLAG1 )
4021 {
4022 1164 canSee = DRAW_INVIS;
4023
1/2
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
1164 if (editorflags & ENEMY_FLAG4) canSee = DRAW_CLOAKED;
4024
2/4
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1164 times.
✗ Branch 3 not taken.
1164 if (dmisc13 >= 0 && (editorflags & ENEMY_FLAG2))
4025 {
4026 if (game->item[dmisc13])
4027 {
4028 canSee = DRAW_NORMAL;
4029 }
4030 //else if ( lensclk && getlensid.flags SHOWINVIS )
4031 //{
4032 //
4033 //}
4034 //else
4035 //{
4036 // if ( (editorflags & ENEMY_FLAG4) ) canSee = DRAW_CLOAKED;
4037 // //otherwisem invisible
4038 //}
4039 }
4040 1164 }
4041 //Room specific
4042 41120787 mapscr* scr = get_scr(screen_spawned);
4043
2/2
✓ Branch 0 taken 38949588 times.
✓ Branch 1 taken 2171199 times.
41120787 if (scr->flags3&fINVISROOM)
4044 {
4045
4/6
✓ Branch 0 taken 2171199 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 226004 times.
✓ Branch 3 taken 1945195 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 226004 times.
2397203 if (canSee == DRAW_NORMAL && !(current_item(itype_amulet)) &&
4046
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226004 times.
226004 !((itemsbuf[Hero.getLastLensID()].flags & item_flag5) && lensclk) && type!=eeGANON) canSee = DRAW_CLOAKED;
4047 2171199 }
4048 //Lens check
4049
2/2
✓ Branch 0 taken 27537 times.
✓ Branch 1 taken 41093250 times.
41120787 if (lensclk)
4050 {
4051
2/2
✓ Branch 0 taken 27105 times.
✓ Branch 1 taken 432 times.
27537 if(flags&guy_lens_only)
4052 {
4053
1/2
✓ Branch 0 taken 432 times.
✗ Branch 1 not taken.
432 if (canSee == DRAW_INVIS) canSee = DRAW_NORMAL;
4054 432 }
4055 27537 }
4056 else
4057 {
4058
2/2
✓ Branch 0 taken 41019834 times.
✓ Branch 1 taken 73416 times.
41093250 if(flags&guy_lens_only)
4059 73416 canSee = DRAW_INVIS;
4060 }
4061
3/4
✓ Branch 0 taken 74580 times.
✓ Branch 1 taken 41046207 times.
✓ Branch 2 taken 74580 times.
✗ Branch 3 not taken.
41120787 if (canSee == DRAW_INVIS && (editorflags & ENEMY_FLAG4)) canSee = DRAW_CLOAKED;
4062
3/4
✓ Branch 0 taken 40820203 times.
✓ Branch 1 taken 300584 times.
✓ Branch 2 taken 40820203 times.
✗ Branch 3 not taken.
41120787 if (canSee == DRAW_NORMAL && (editorflags & ENEMY_FLAG16)) canSee = DRAW_CLOAKED;
4063
4064
2/2
✓ Branch 0 taken 41046207 times.
✓ Branch 1 taken 74580 times.
41120787 if (canSee == DRAW_INVIS)
4065 74580 return;
4066
4067
4/4
✓ Branch 0 taken 41043832 times.
✓ Branch 1 taken 2375 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 41043825 times.
41046207 if(fallclk||drownclk)
4068 {
4069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2382 times.
2382 if (canSee == DRAW_CLOAKED)
4070 {
4071 sprite::drawcloaked(dest);
4072 }
4073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2382 times.
2382 else if (canSee == DRAW_NORMAL)
4074 {
4075 2382 sprite::draw(dest);
4076 2382 }
4077 2382 return;
4078 }
4079 41043825 int32_t cshold=cs;
4080
4081
2/2
✓ Branch 0 taken 904261 times.
✓ Branch 1 taken 40139564 times.
41043825 if(dying)
4082 {
4083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 904261 times.
904261 if(clk2>=19)
4084 {
4085 if(!(clk2&2))
4086 {
4087 //if the enemy isn't totally invisible, or if it is, but Hero has the item needed to reveal it, draw it.
4088 if (canSee == DRAW_CLOAKED)
4089 {
4090 sprite::drawcloaked(dest);
4091 }
4092 else if (canSee == DRAW_NORMAL)
4093 {
4094 sprite::draw(dest);
4095 }
4096 }
4097 return;
4098 }
4099
4100 904261 flip = 0;
4101 904261 tile = wpnsbuf[spr_death].tile;
4102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 904261 times.
904261 if ( do_animation )
4103 {
4104 904261 int32_t offs = 0;
4105
2/2
✓ Branch 0 taken 853112 times.
✓ Branch 1 taken 51149 times.
904261 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4106 {
4107
2/2
✓ Branch 0 taken 49521 times.
✓ Branch 1 taken 1628 times.
51149 if(clk2 > 2)
4108 {
4109 1628 spr_death_anim_clk=0;
4110 1628 clk2=1;
4111
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1614 times.
1628 if(hp > -1000)
4112 1614 death_sfx();
4113 1628 }
4114
4/4
✓ Branch 0 taken 38450 times.
✓ Branch 1 taken 12699 times.
✓ Branch 2 taken 402 times.
✓ Branch 3 taken 38048 times.
51149 if(clk2==1 && spr_death_anim_clk>-1)
4115 {
4116 38048 ++clk2;
4117
2/2
✓ Branch 0 taken 2382 times.
✓ Branch 1 taken 35666 times.
38048 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4118
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 38027 times.
38048 spr_death_anim_frm *= zc_max(1,txsz);
4119 38048 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4120
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 37972 times.
38048 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4121
6/6
✓ Branch 0 taken 2382 times.
✓ Branch 1 taken 35666 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 38046 times.
✓ Branch 4 taken 36438 times.
✓ Branch 5 taken 1610 times.
38048 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4122 {
4123 1610 spr_death_anim_clk=-1;
4124 1610 clk2=1;
4125 1610 }
4126 38048 }
4127 51149 tile += spr_death_anim_frm;
4128 51149 }
4129
2/2
✓ Branch 0 taken 315607 times.
✓ Branch 1 taken 537505 times.
853112 else if(BSZ)
4130 {
4131
2/2
✓ Branch 0 taken 248172 times.
✓ Branch 1 taken 67435 times.
315607 offs = zc_min((15-clk2)/3,4);
4132 315607 }
4133
4/4
✓ Branch 0 taken 358415 times.
✓ Branch 1 taken 179090 times.
✓ Branch 2 taken 179079 times.
✓ Branch 3 taken 179336 times.
537505 else if(clk2>6 && clk2<=12)
4134 {
4135 179336 offs = 1;
4136 179336 }
4137
4138
2/2
✓ Branch 0 taken 455768 times.
✓ Branch 1 taken 448493 times.
904261 if(offs)
4139 {
4140
2/2
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 448043 times.
448493 offs *= zc_max(1,txsz);
4141 448493 int32_t rows = TILEROW(tile+offs)-TILEROW(tile);
4142
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 448055 times.
448493 offs += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4143 448493 }
4144 904261 tile += offs;
4145 904261 }
4146
4147
6/6
✓ Branch 0 taken 853112 times.
✓ Branch 1 taken 51149 times.
✓ Branch 2 taken 537505 times.
✓ Branch 3 taken 315607 times.
✓ Branch 4 taken 189182 times.
✓ Branch 5 taken 348323 times.
904261 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4148 555938 cs = wpnsbuf[spr_death].csets&15;
4149 else
4150 348323 cs = (((clk2+5)>>1)&3)+6;
4151 904261 }
4152
3/4
✓ Branch 0 taken 1204162 times.
✓ Branch 1 taken 38935402 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1204162 times.
40139564 else if(hclk>0 && getCanFlicker())
4153 {
4154 1204162 cs = getFlashingCSet();
4155 1204162 }
4156 //draw every other frame for flickering enemies
4157
2/2
✓ Branch 0 taken 248031 times.
✓ Branch 1 taken 40795794 times.
41043825 if (is_hitflickerframe(false))
4158 {
4159
5/6
✓ Branch 0 taken 90246 times.
✓ Branch 1 taken 157785 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 90245 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 157786 times.
248031 int32_t temp_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
4160
2/4
✓ Branch 0 taken 248031 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 248031 times.
248031 if (game->get_spriteflickercolor() || temp_flicker_color)
4161 {
4162 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
4163 sprite_flicker_color = temp_flicker_color;
4164 sprite::draw(dest);
4165 }
4166 248031 }
4167 else
4168 {
4169
2/2
✓ Branch 0 taken 225162 times.
✓ Branch 1 taken 40570632 times.
40795794 if (canSee == DRAW_CLOAKED)
4170 {
4171 225162 sprite::drawcloaked(dest);
4172 225162 }
4173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40570632 times.
40570632 else if (canSee == DRAW_NORMAL)
4174 {
4175
1/2
✓ Branch 0 taken 40570632 times.
✗ Branch 1 not taken.
40570632 if ( frozenclock < 0 )
4176 {
4177 if ( frozentile > 0 ) tile = frozentile;
4178 loadpalset(csBOSS,frozencset);
4179 }
4180 40570632 sprite::draw(dest);
4181 40570632 }
4182 }
4183 41043825 cs=cshold;
4184 44971115 }
4185
4186 //old zc bosses
4187 40943259 void enemy::drawzcboss(BITMAP *dest)
4188 {
4189 40943259 didScriptThisFrame = false; //Since there's no better place to put it
4190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40943259 times.
40943259 if(dont_draw())
4191 return;
4192
4193 40943259 int32_t cshold=cs;
4194
4195
2/2
✓ Branch 0 taken 784038 times.
✓ Branch 1 taken 40159221 times.
40943259 if(dying)
4196 {
4197
2/2
✓ Branch 0 taken 3960 times.
✓ Branch 1 taken 780078 times.
784038 if(clk2>=19)
4198 {
4199
2/2
✓ Branch 0 taken 1980 times.
✓ Branch 1 taken 1980 times.
3960 if(!(clk2&2))
4200 1980 sprite::drawzcboss(dest);
4201
4202 3960 return;
4203 }
4204
4205 780078 flip = 0;
4206 780078 tile = wpnsbuf[spr_death].tile;
4207
4208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780078 times.
780078 if ( do_animation )
4209 {
4210
2/2
✓ Branch 0 taken 775562 times.
✓ Branch 1 taken 4516 times.
780078 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4211 {
4212
2/2
✓ Branch 0 taken 4510 times.
✓ Branch 1 taken 6 times.
4516 if(clk2 > 2)
4213 {
4214 6 spr_death_anim_clk=0;
4215 6 clk2=1;
4216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(hp > -1000)
4217 6 death_sfx();
4218 6 }
4219
4/4
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 4256 times.
✓ Branch 2 taken 184 times.
✓ Branch 3 taken 76 times.
4516 if(clk2==1 && spr_death_anim_clk>-1)
4220 {
4221 76 ++clk2;
4222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm *= zc_max(1,txsz);
4224 76 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4226
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 76 times.
✓ Branch 4 taken 74 times.
✓ Branch 5 taken 2 times.
76 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4227 {
4228 2 spr_death_anim_clk=-1;
4229 2 clk2=1;
4230 2 }
4231 76 }
4232 4516 tile += spr_death_anim_frm;
4233 4516 }
4234
2/2
✓ Branch 0 taken 278586 times.
✓ Branch 1 taken 496976 times.
775562 else if(BSZ)
4235
2/2
✓ Branch 0 taken 219134 times.
✓ Branch 1 taken 59452 times.
278586 tile += zc_min((15-clk2)/3,4);
4236
4/4
✓ Branch 0 taken 331281 times.
✓ Branch 1 taken 165695 times.
✓ Branch 2 taken 165538 times.
✓ Branch 3 taken 165743 times.
496976 else if(clk2>6 && clk2<=12)
4237 165743 ++tile;
4238 780078 }
4239
4240
6/6
✓ Branch 0 taken 775562 times.
✓ Branch 1 taken 4516 times.
✓ Branch 2 taken 496976 times.
✓ Branch 3 taken 278586 times.
✓ Branch 4 taken 183872 times.
✓ Branch 5 taken 313104 times.
780078 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4241 466974 cs = wpnsbuf[spr_death].csets&15;
4242 else
4243 313104 cs = (((clk2+5)>>1)&3)+6;
4244 780078 }
4245
2/2
✓ Branch 0 taken 38944531 times.
✓ Branch 1 taken 1214690 times.
40159221 else if(hclk>0)
4246 {
4247 1214690 cs = getFlashingCSet();
4248 1214690 }
4249
4250 40939299 mapscr* scr = get_scr(screen_spawned);
4251
4252
3/4
✓ Branch 0 taken 2045619 times.
✓ Branch 1 taken 38893680 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7543 times.
40946842 if((scr->flags3&fINVISROOM) &&
4253
2/2
✓ Branch 0 taken 7543 times.
✓ Branch 1 taken 2038076 times.
2045619 !(current_item(itype_amulet)) &&
4254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7543 times.
7543 !(get_qr(qr_LENSSEESENEMIES) &&
4255 7543 lensclk) && type!=eeGANON)
4256 {
4257 7543 sprite::drawcloaked(dest);
4258 7543 }
4259 else
4260 {
4261
2/2
✓ Branch 0 taken 23473 times.
✓ Branch 1 taken 40908283 times.
40931756 if (is_hitflickerframe(true))
4262 {
4263
4/6
✓ Branch 0 taken 885 times.
✓ Branch 1 taken 22588 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 885 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22588 times.
23473 int32_t temp_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
4264
1/2
✓ Branch 0 taken 23473 times.
✗ Branch 1 not taken.
23473 if (game->get_spriteflickercolor())
4265 {
4266 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
4267 sprite_flicker_color = temp_flicker_color;
4268 sprite::drawzcboss(dest);
4269 }
4270 23473 }
4271 else
4272 40908283 sprite::drawzcboss(dest);
4273 }
4274
4275 40939299 cs=cshold;
4276 40943259 }
4277
4278
4279 // similar to the overblock function--can do up to a 32x32 sprite
4280 //will this play nicely with scripttile, solely using the modifications in sprite::draw()?
4281 323235 void enemy::drawblock(BITMAP *dest,int32_t mask)
4282 {
4283 323235 int32_t thold=tile;
4284 323235 int32_t t1=tile;
4285 323235 int32_t t2=tile+20;
4286 323235 int32_t t3=tile+1;
4287 323235 int32_t t4=tile+21;
4288
4289
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 323235 times.
323235 switch(mask)
4290 {
4291 case 1:
4292 enemy::drawzcboss(dest);
4293 break;
4294
4295 case 3:
4296 if(flip&2)
4297 zc_swap(t1,t2);
4298
4299 tile=t1;
4300 enemy::drawzcboss(dest);
4301 tile=t2;
4302 yofs+=16;
4303 enemy::drawzcboss(dest);
4304 yofs-=16;
4305 break;
4306
4307 case 5:
4308 t2=tile+1;
4309
4310 if(flip&1)
4311 zc_swap(t1,t2);
4312
4313 tile=t1;
4314 enemy::drawzcboss(dest);
4315 tile=t2;
4316 xofs+=16;
4317 enemy::drawzcboss(dest);
4318 xofs-=16;
4319 break;
4320
4321 case 15:
4322
2/2
✓ Branch 0 taken 316479 times.
✓ Branch 1 taken 6756 times.
323235 if(flip&1)
4323 {
4324 6756 zc_swap(t1,t3);
4325 6756 zc_swap(t2,t4);
4326 6756 }
4327
4328
1/2
✓ Branch 0 taken 323235 times.
✗ Branch 1 not taken.
323235 if(flip&2)
4329 {
4330 zc_swap(t1,t2);
4331 zc_swap(t3,t4);
4332 }
4333
4334 323235 tile=t1;
4335 323235 enemy::drawzcboss(dest);
4336 323235 tile=t2;
4337 323235 yofs+=16;
4338 323235 enemy::drawzcboss(dest);
4339 323235 yofs-=16;
4340 323235 tile=t3;
4341 323235 xofs+=16;
4342 323235 enemy::drawzcboss(dest);
4343 323235 tile=t4;
4344 323235 yofs+=16;
4345 323235 enemy::drawzcboss(dest);
4346 323235 xofs-=16;
4347 323235 yofs-=16;
4348 323235 break;
4349 }
4350
4351 323235 tile=thold;
4352 323235 }
4353
4354 20383527 void enemy::drawshadow(BITMAP *dest, bool translucent)
4355 {
4356
4/4
✓ Branch 0 taken 18372181 times.
✓ Branch 1 taken 2011346 times.
✓ Branch 2 taken 526918 times.
✓ Branch 3 taken 17845263 times.
20383527 if(dont_draw() || isSideViewGravity())
4357 {
4358 2538264 return;
4359 }
4360
4361
2/2
✓ Branch 0 taken 327632 times.
✓ Branch 1 taken 17517631 times.
17845263 if(dying)
4362 {
4363 327632 return;
4364 }
4365
4366 17517631 mapscr* scr = get_scr(screen_spawned);
4367
4/4
✓ Branch 0 taken 1718249 times.
✓ Branch 1 taken 15799382 times.
✓ Branch 2 taken 347010 times.
✓ Branch 3 taken 17170621 times.
17517631 if(((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))||
4368 17517631 (darkroom))
4369 {
4370 347010 return;
4371 }
4372 else
4373 {
4374
4/4
✓ Branch 0 taken 16571466 times.
✓ Branch 1 taken 599155 times.
✓ Branch 2 taken 16523997 times.
✓ Branch 3 taken 47469 times.
17170621 if(enemycanfall(id, false) && shadowtile == 0)
4375 47469 shadowtile = wpnsbuf[spr_shadow].tile;
4376
4377
5/6
✓ Branch 0 taken 16226739 times.
✓ Branch 1 taken 943882 times.
✓ Branch 2 taken 16226739 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15627584 times.
✓ Branch 5 taken 599155 times.
17170621 if(z>0 || fakez>0 || !enemycanfall(id, false))
4378 {
4379
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 1542762 times.
1543037 if(!shadow_overpit(this))
4380 1542762 sprite::drawshadow(dest,translucent);
4381 1543037 }
4382 }
4383 20383527 }
4384
4385 129181 void enemy::masked_draw(BITMAP *dest,int32_t mx,int32_t my,int32_t mw,int32_t mh)
4386 {
4387 129181 BITMAP *sub=create_sub_bitmap(dest,mx,my,mw,mh);
4388
4389
1/2
✓ Branch 0 taken 129181 times.
✗ Branch 1 not taken.
129181 if(sub!=NULL)
4390 {
4391 129181 xofs-=mx;
4392 129181 yofs-=my;
4393 129181 enemy::draw(sub);
4394 129181 xofs+=mx;
4395 129181 yofs+=my;
4396 129181 destroy_bitmap(sub);
4397 129181 }
4398 else
4399 enemy::draw(dest);
4400 129181 }
4401
4402 9 void enemy::init_size_flags()
4403 {
4404
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
9 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; }
4405
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
9 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
4406
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
9 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
4407
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
9 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
4408
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
4409
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
4410
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
4411
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
4412
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
4413 {
4414 yofs = (int32_t)d->yofs;
4415 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset);
4416 }
4417
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
4418 9 }
4419
4420 // override hit detection to check for invicibility, stunned, etc
4421 112664439 bool enemy::hit()
4422 {
4423
4/4
✓ Branch 0 taken 111337172 times.
✓ Branch 1 taken 1327267 times.
✓ Branch 2 taken 109522516 times.
✓ Branch 3 taken 1814656 times.
112664439 if(dying || hclk>0) return false;
4424 109522516 return sprite::hit();
4425 112664439 }
4426 730351 bool enemy::hit(sprite *s)
4427 {
4428
3/4
✓ Branch 0 taken 730351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 713374 times.
✓ Branch 3 taken 16977 times.
730351 if(!hit() || !s->hit()) return false;
4429 713374 return sprite::hit(s);
4430 730351 }
4431
4432 44723304 bool enemy::hit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz2,int32_t tysz2,int32_t tzsz2)
4433 {
4434
2/2
✓ Branch 0 taken 3973386 times.
✓ Branch 1 taken 40749918 times.
44723304 if(!hit()) return false;
4435 40749918 return sprite::hit(tx,ty,tz,txsz2,tysz2,tzsz2);
4436 44723304 }
4437 78011 bool enemy::hit(int32_t tx,int32_t ty,int32_t txsz2,int32_t tysz2)
4438 {
4439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78011 times.
78011 if(!hit()) return false;
4440 78011 return sprite::hit(tx,ty,txsz2,tysz2);
4441 78011 }
4442
4443 11190904 bool enemy::hit(weapon *w)
4444 {
4445
2/2
✓ Branch 0 taken 1196298 times.
✓ Branch 1 taken 9994606 times.
11190904 if(!hit()) return false;
4446
4447
2/2
✓ Branch 0 taken 6647382 times.
✓ Branch 1 taken 3347224 times.
9994606 if (replay_version_check(0, 14))
4448 {
4449
4/6
✓ Branch 0 taken 6422331 times.
✓ Branch 1 taken 225051 times.
✓ Branch 2 taken 6422331 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6422331 times.
✗ Branch 5 not taken.
6647382 if(!w->scriptcoldet || w->fallclk || w->drownclk)
4450 225051 return false;
4451 6422331 return sprite::hit(w);
4452 }
4453 3347224 return w->hit(this);
4454 11190904 }
4455
4456 38124564 bool enemy::can_pitfall(bool checkspawning)
4457 {
4458
4/4
✓ Branch 0 taken 36552358 times.
✓ Branch 1 taken 1572206 times.
✓ Branch 2 taken 36539384 times.
✓ Branch 3 taken 1585180 times.
38124564 if((fading||isspawning)&&checkspawning) return false; //Don't fall during spawn.
4459
2/2
✓ Branch 0 taken 29877757 times.
✓ Branch 1 taken 6661627 times.
36539384 switch(guysbuf[id&0xFFF].type)
4460 {
4461 case eeAQUA:
4462 case eeDIG:
4463 case eeDONGO:
4464 case eeFAIRY:
4465 case eeGANON:
4466 case eeGHOMA:
4467 case eeGLEEOK:
4468 case eeGUY:
4469 case eeLANM:
4470 case eeMANHAN:
4471 case eeMOLD:
4472 case eeNONE:
4473 case eePATRA:
4474 case eeZORA:
4475 6661627 return false; //Disallowed types
4476 default:
4477 29877757 return true;
4478 }
4479 38124564 }
4480 //Handle death
4481 38009335 void enemy::try_death(bool force_kill)
4482 {
4483
8/8
✓ Branch 0 taken 37952766 times.
✓ Branch 1 taken 56569 times.
✓ Branch 2 taken 37952755 times.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 43653 times.
✓ Branch 5 taken 37909102 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 43652 times.
38009335 if(!dying && (force_kill || (hp<=0 && !immortal)))
4484 {
4485 43663 std::vector<int32_t> &ev = FFCore.eventData;
4486 43663 ev.clear();
4487 43663 ev.push_back(10000);
4488 43663 ev.push_back(getUID());
4489
4490 43663 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DEATH);
4491 43663 bool isSaved = !ev[0];
4492 43663 ev.clear();
4493
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43663 times.
43663 if(isSaved) return;
4494
4495
4/4
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 43613 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 44 times.
43663 if (itemguy && get_screen_state(screen_spawned).item_state == ScreenItemState::CarriedByEnemy)
4496 {
4497
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 44 times.
95 for(int32_t i=0; i<items.Count(); i++)
4498 {
4499
4/4
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 44 times.
51 if(((item*)items.spr(i))->pickup&ipENEMY && screen_spawned == ((item*)items.spr(i))->screen_spawned)
4500 {
4501
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 3 times.
44 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
4502 {
4503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
4504 {
4505 items.spr(i)->x = x+hxofs+(hit_width/2)-8;
4506 items.spr(i)->y = y+hyofs+(hit_height/2)-10-fakez;
4507 }
4508 else
4509 {
4510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(extend >= 3)
4511 {
4512 items.spr(i)->x = x+(txsz-1)*8;
4513 items.spr(i)->y = y-2+(tysz-1)*8;
4514 }
4515 else
4516 {
4517 3 items.spr(i)->x = x;
4518 3 items.spr(i)->y = y - 2;
4519 }
4520 }
4521 3 items.spr(i)->z = z;
4522 3 items.spr(i)->fakez = fakez;
4523 3 }
4524 else
4525 {
4526 41 items.spr(i)->x = x;
4527 41 items.spr(i)->y = y - 2;
4528 }
4529 44 }
4530 51 }
4531 44 }
4532
4533 43663 dying=true;
4534
4535
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 43631 times.
43663 if(fading==fade_flash_die)
4536 32 clk2=19+18*4;
4537 else
4538 {
4539 43631 clk2 = BSZ ? 15 : 19;
4540
4541
2/2
✓ Branch 0 taken 21062 times.
✓ Branch 1 taken 22569 times.
43631 if(fading!=fade_blue_poof)
4542 22569 fading=0;
4543 }
4544
4545
2/2
✓ Branch 0 taken 43613 times.
✓ Branch 1 taken 50 times.
43663 if(itemguy)
4546 {
4547 50 screen_item_set_state(screen_spawned, ScreenItemState::None);
4548 50 item_set=0;
4549 50 }
4550
6/6
✓ Branch 0 taken 42609 times.
✓ Branch 1 taken 1054 times.
✓ Branch 2 taken 33920 times.
✓ Branch 3 taken 8689 times.
✓ Branch 4 taken 1428 times.
✓ Branch 5 taken 32492 times.
43663 if (screen_spawned < 128 && count_enemy && !script_spawned)
4551 32492 game->guys[mapind(cur_map, screen_spawned)] -= 1;
4552 43663 }
4553 38009335 }
4554
4555 // --==**==--
4556
4557 // Movement routines that can be used by derived classes as needed
4558
4559 // --==**==--
4560
4561 556554 void enemy::fix_coords(bool bound)
4562 {
4563
1/2
✓ Branch 0 taken 556554 times.
✗ Branch 1 not taken.
556554 if ((get_qr(qr_OUTOFBOUNDSENEMIES) ? 1 : 0) ^ ((editorflags&ENEMY_FLAG11)?1:0)) return;
4564
1/2
✓ Branch 0 taken 556554 times.
✗ Branch 1 not taken.
556554 if(moveflags & move_ignore_screenedge) bound = false;
4565
4566
2/2
✓ Branch 0 taken 81680 times.
✓ Branch 1 taken 474874 times.
556554 if(bound)
4567 {
4568 474874 int w = world_w;
4569 474874 int h = world_h;
4570
4571
1/2
✓ Branch 0 taken 474874 times.
✗ Branch 1 not taken.
474874 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
4572 {
4573
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 474872 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
474874 x=vbound(x, 0, (( guysbuf[id].SIZEflags&OVERRIDE_TILE_WIDTH && !isflier(id) ) ? (w-((txsz-1)*16)) : w-16));
4574
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 474872 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
474874 y=vbound(y, 0,(( guysbuf[id].SIZEflags&OVERRIDE_TILE_HEIGHT && !isflier(id) ) ? (h-((txsz-1)*16)) : h-16));
4575 474874 }
4576 else
4577 {
4578 x=vbound(x, 0, w-16);
4579 y=vbound(y, 0, h-16);
4580 }
4581 474874 }
4582
4583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556554 times.
556554 if(!OUTOFBOUNDS(id, x, y))
4584 {
4585 556554 do_fix(x, 16, true);
4586
2/2
✓ Branch 0 taken 1139 times.
✓ Branch 1 taken 555415 times.
556554 if(isSideViewGravity())
4587 1139 do_fix(y,8,true);
4588 555415 else do_fix(y,16,true);
4589 556554 }
4590 556554 }
4591 9176 bool enemy::cannotpenetrate()
4592 {
4593
4/4
✓ Branch 0 taken 8995 times.
✓ Branch 1 taken 181 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 8957 times.
9176 return (type == eeAQUA || type == eeMANHAN || type == eeGHOMA);
4594 }
4595
4596 562 bool enemy::canmove_old(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
4597 {
4598 bool ok;
4599 562 int32_t dx = 0, dy = 0;
4600 562 int32_t sv = 8;
4601
4602 //Why is this here??? Why is it needed???
4603 562 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4604
4605
8/9
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 85 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 78 times.
✓ Branch 6 taken 57 times.
✓ Branch 7 taken 81 times.
✗ Branch 8 not taken.
562 switch(ndir)
4606 {
4607 case 8:
4608 case up:
4609
3/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
69 if(canfall(id) && isSideViewGravity())
4610 return false;
4611
4612 69 dy = dy1-s;
4613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 special = (special==spw_clipbottomright)?spw_none:special;
4614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4615 69 break;
4616
4617 case 12:
4618 case down:
4619
3/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
51 if(canfall(id) && isSideViewGravity())
4620 return false;
4621
4622 51 dy = dy2+s;
4623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4624 51 break;
4625
4626 case 14:
4627 case left:
4628 47 dx = dx1-s;
4629 47 sv = ((isSideViewGravity())?7:8);
4630
2/4
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 47 times.
47 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4631
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 45 times.
47 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4632 47 break;
4633
4634 case 10:
4635 case right:
4636 85 dx = dx2+s;
4637 85 sv = ((isSideViewGravity())?7:8);
4638
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 79 times.
85 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4639 85 break;
4640
4641 case 9:
4642 case r_up:
4643 94 dx = dx2+s;
4644 94 dy = dy1-s;
4645
3/4
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✓ Branch 3 taken 1 times.
187 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4647 94 break;
4648
4649 case 11:
4650 case r_down:
4651 78 dx = dx2+s;
4652 78 dx = dy2+s;
4653
3/4
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 1 times.
155 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4655 78 break;
4656
4657 case 13:
4658 case l_down:
4659 57 dx = dx1-s;
4660 57 dy = dy2+s;
4661
3/4
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
112 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4663 57 break;
4664
4665 case 15:
4666 case l_up:
4667 81 dx = dx1-s;
4668 81 dy = dy1-s;
4669
3/4
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 1 times.
161 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4671 81 break;
4672
4673 default:
4674 db=99;
4675 return true;
4676 }
4677
4678 562 return ok;
4679 562 }
4680
4681
4682
4683
4684 // returns true if next step is ok, false if there is something there
4685 7360028 bool enemy::canmove(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2, bool kb)
4686 {
4687 7360028 bool ok = false; //initialise the var, son't just declare it
4688 7360028 int32_t dx = 0, dy = 0;
4689 7360028 int32_t sv = 8;
4690 7360028 int32_t tries = 2; int32_t try_x = 0; int32_t try_y = 0;
4691 //Why is this here??? Why is it needed???
4692 7360028 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7360028 times.
7360028 int32_t usexoffs = (SIZEflags&OVERRIDE_HIT_X_OFFSET) ? hxofs : 0;
4694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7360028 times.
7360028 int32_t useyoffs = (SIZEflags&OVERRIDE_HIT_Y_OFFSET) ? hyofs : 0;
4695
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 7360015 times.
7360028 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
4696
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 7360015 times.
7360028 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4697 7360028 bool offgrid = OFFGRID_ENEMY;
4698
2/2
✓ Branch 0 taken 7291 times.
✓ Branch 1 taken 7352737 times.
7360028 if(!offgrid)
4699 {
4700 //Enemies smaller than 1-tile must act as 1-tile large, if off-grid movement is disabled.
4701
1/2
✓ Branch 0 taken 7352737 times.
✗ Branch 1 not taken.
7352737 if(usehei<16)usehei=16;
4702
1/2
✓ Branch 0 taken 7352737 times.
✗ Branch 1 not taken.
7352737 if(usewid<16)usewid=16;
4703 7352737 }
4704
9/9
✓ Branch 0 taken 1331317 times.
✓ Branch 1 taken 1107763 times.
✓ Branch 2 taken 1227757 times.
✓ Branch 3 taken 1218339 times.
✓ Branch 4 taken 540601 times.
✓ Branch 5 taken 642269 times.
✓ Branch 6 taken 603869 times.
✓ Branch 7 taken 568437 times.
✓ Branch 8 taken 119676 times.
7360028 switch(ndir) //need to check every 8 pixels between two points
4705 {
4706 case 8:
4707 case up:
4708 {
4709
4/4
✓ Branch 0 taken 150808 times.
✓ Branch 1 taken 1180509 times.
✓ Branch 2 taken 150148 times.
✓ Branch 3 taken 660 times.
1331317 if(enemycanfall(id) && isSideViewGravity())
4710 660 return false;
4711
4712 1330657 dy = dy1-s;
4713
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 1330177 times.
1330657 special = (special==spw_clipbottomright)?spw_none:special;
4714 1330657 tries = usewid/(offgrid ? 8 : 16);
4715
4716
2/2
✓ Branch 0 taken 1130437 times.
✓ Branch 1 taken 1331307 times.
2461744 for ( ; tries > 0; --tries )
4717 {
4718
2/2
✓ Branch 0 taken 197596 times.
✓ Branch 1 taken 1133711 times.
1331307 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy, special,kb);
4719 1331307 try_x += (offgrid ? 8 : 16);
4720
2/2
✓ Branch 0 taken 1131087 times.
✓ Branch 1 taken 200220 times.
1331307 if (!ok) break;
4721 1131087 }
4722
2/2
✓ Branch 0 taken 1130437 times.
✓ Branch 1 taken 200220 times.
1330657 if(!ok) break;
4723
1/2
✓ Branch 0 taken 1130437 times.
✗ Branch 1 not taken.
1130437 if((usewid%16)>0) //Uneven width
4724 {
4725 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy, special,kb);
4726 }
4727 1130437 break;
4728 }
4729 case 12:
4730 case down:
4731 {
4732
4/4
✓ Branch 0 taken 180701 times.
✓ Branch 1 taken 927062 times.
✓ Branch 2 taken 179975 times.
✓ Branch 3 taken 726 times.
1107763 if(enemycanfall(id) && isSideViewGravity())
4733 726 return false;
4734
4735 1107037 dy = dy2+s;
4736 1107037 tries = usewid/(offgrid ? 8 : 16);
4737
2/2
✓ Branch 0 taken 900644 times.
✓ Branch 1 taken 1107821 times.
2008465 for ( ; tries > 0; --tries )
4738 {
4739
3/4
✓ Branch 0 taken 205645 times.
✓ Branch 1 taken 902176 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 902176 times.
1107821 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4740 1107821 try_x += (offgrid ? 8 : 16);
4741
2/2
✓ Branch 0 taken 901428 times.
✓ Branch 1 taken 206393 times.
1107821 if (!ok) break;
4742 901428 }
4743
2/2
✓ Branch 0 taken 900644 times.
✓ Branch 1 taken 206393 times.
1107037 if(!ok) break;
4744
1/2
✓ Branch 0 taken 900644 times.
✗ Branch 1 not taken.
900644 if((usewid%16)>0) //Uneven width
4745 {
4746 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4747 }
4748 900644 break;
4749 }
4750 case 14:
4751 case left:
4752 {
4753 1227757 dx = dx1-s;
4754 1227757 sv = ((isSideViewGravity())?7:0);
4755
4/4
✓ Branch 0 taken 1227134 times.
✓ Branch 1 taken 623 times.
✓ Branch 2 taken 1768 times.
✓ Branch 3 taken 1225366 times.
1227757 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4756 1227757 tries = usehei/(offgrid ? 8 : 16);
4757
2/2
✓ Branch 0 taken 1028543 times.
✓ Branch 1 taken 1228674 times.
2257217 for ( ; tries > 0; --tries )
4758 {
4759
2/2
✓ Branch 0 taken 198029 times.
✓ Branch 1 taken 1030645 times.
1228674 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+try_y, special,kb);
4760 1228674 try_y += (offgrid ? 8 : 16);
4761
2/2
✓ Branch 0 taken 1029460 times.
✓ Branch 1 taken 199214 times.
1228674 if (!ok) break;
4762 1029460 }
4763
2/2
✓ Branch 0 taken 1028543 times.
✓ Branch 1 taken 199214 times.
1227757 if(!ok) break;
4764
1/2
✓ Branch 0 taken 1028543 times.
✗ Branch 1 not taken.
1028543 if((usehei%16)>0) //Uneven height
4765 {
4766 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+usehei-1, special,kb);
4767 }
4768 1028543 break;
4769 }
4770 case 10:
4771 case right:
4772 {
4773 1218339 dx = dx2+s;
4774 1218339 sv = ((isSideViewGravity())?7:0);
4775 1218339 tries = usehei/(offgrid ? 8 : 16);
4776
2/2
✓ Branch 0 taken 1030011 times.
✓ Branch 1 taken 1219233 times.
2249244 for ( ; tries > 0; --tries )
4777 {
4778
3/4
✓ Branch 0 taken 186973 times.
✓ Branch 1 taken 1032260 times.
✓ Branch 2 taken 1032260 times.
✗ Branch 3 not taken.
1219233 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+try_y, special,kb);
4779 1219233 try_y += (offgrid ? 8 : 16);
4780
2/2
✓ Branch 0 taken 1030905 times.
✓ Branch 1 taken 188328 times.
1219233 if (!ok) break;
4781 1030905 }
4782
2/2
✓ Branch 0 taken 1030011 times.
✓ Branch 1 taken 188328 times.
1218339 if(!ok) break;
4783
1/2
✓ Branch 0 taken 1030011 times.
✗ Branch 1 not taken.
1030011 if((usehei%16)>0) //Uneven height
4784 {
4785 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+usehei-1, special,kb);
4786 }
4787 1030011 break;
4788 }
4789 case 9:
4790 case r_up:
4791 {
4792 540601 dx = dx2+s;
4793 540601 dy = dy1-s;
4794 540601 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4795 540601 sv = ((isSideViewGravity())?7:0);
4796
2/2
✓ Branch 0 taken 523541 times.
✓ Branch 1 taken 540601 times.
1064142 for ( ; tries_x > 0; --tries_x )
4797 {
4798 540601 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4799 540601 try_y = 0;
4800
2/2
✓ Branch 0 taken 523541 times.
✓ Branch 1 taken 540601 times.
1064142 for ( ; tries_y > 0; --tries_y )
4801 {
4802
4/4
✓ Branch 0 taken 532330 times.
✓ Branch 1 taken 8271 times.
✓ Branch 2 taken 526882 times.
✓ Branch 3 taken 5448 times.
1067483 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4803
2/2
✓ Branch 0 taken 2392 times.
✓ Branch 1 taken 524490 times.
526882 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4804 540601 try_y += (offgrid ? 8 : 16);
4805
2/2
✓ Branch 0 taken 523541 times.
✓ Branch 1 taken 17060 times.
540601 if (!ok) break;
4806 523541 }
4807
2/2
✓ Branch 0 taken 523541 times.
✓ Branch 1 taken 17060 times.
540601 if (!ok) break;
4808
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 523541 times.
523541 if((usehei%16)>0) //Uneven height
4809 {
4810 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4811 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4812 }
4813 523541 try_x += (offgrid ? 8 : 16);
4814 523541 }
4815
2/2
✓ Branch 0 taken 523541 times.
✓ Branch 1 taken 17060 times.
540601 if(!ok) break;
4816
1/2
✓ Branch 0 taken 523541 times.
✗ Branch 1 not taken.
523541 if((usewid%16)>0) //Uneven width
4817 {
4818 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4819 try_y = 0;
4820 for ( ; tries_y > 0; --tries_y )
4821 {
4822 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4823 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4824 try_y += (offgrid ? 8 : 16);
4825 if (!ok) break;
4826 }
4827 if (!ok) break;
4828 if((usehei%16)>0) //Uneven height
4829 {
4830 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4831 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4832 }
4833 }
4834 523541 break;
4835 }
4836 case 11:
4837 case r_down:
4838 {
4839 642269 dx = dx2+s;
4840 642269 dx = dy2+s;
4841 642269 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4842 //sv = ((isSideViewGravity())?7:0);
4843
2/2
✓ Branch 0 taken 626871 times.
✓ Branch 1 taken 642269 times.
1269140 for ( ; tries_x > 0; --tries_x )
4844 {
4845 642269 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4846 642269 try_y = 0;
4847
2/2
✓ Branch 0 taken 626871 times.
✓ Branch 1 taken 642269 times.
1269140 for ( ; tries_y > 0; --tries_y )
4848 {
4849
4/4
✓ Branch 0 taken 640758 times.
✓ Branch 1 taken 1511 times.
✓ Branch 2 taken 627938 times.
✓ Branch 3 taken 12820 times.
1270207 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4850
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 627832 times.
627938 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4851 642269 try_y += (offgrid ? 8 : 16);
4852
2/2
✓ Branch 0 taken 626871 times.
✓ Branch 1 taken 15398 times.
642269 if (!ok) break;
4853 626871 }
4854
2/2
✓ Branch 0 taken 626871 times.
✓ Branch 1 taken 15398 times.
642269 if (!ok) break;
4855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 626871 times.
626871 if((usehei%16)>0) //Uneven height
4856 {
4857 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4858 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4859 }
4860 626871 try_x += (offgrid ? 8 : 16);
4861 626871 }
4862
2/2
✓ Branch 0 taken 626871 times.
✓ Branch 1 taken 15398 times.
642269 if(!ok) break;
4863
1/2
✓ Branch 0 taken 626871 times.
✗ Branch 1 not taken.
626871 if((usewid%16)>0) //Uneven width
4864 {
4865 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4866 try_y = 0;
4867 for ( ; tries_y > 0; --tries_y )
4868 {
4869 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4870 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4871 try_y += (offgrid ? 8 : 16);
4872 if (!ok) break;
4873 }
4874 if (!ok) break;
4875 if((usehei%16)>0) //Uneven height
4876 {
4877 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4878 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4879 }
4880 }
4881 626871 break;
4882 }
4883 case 13:
4884 case l_down:
4885 {
4886 603869 dx = dx1-s;
4887 603869 dy = dy2+s;
4888 603869 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4889 //sv = ((isSideViewGravity())?7:0);
4890
2/2
✓ Branch 0 taken 586793 times.
✓ Branch 1 taken 603869 times.
1190662 for ( ; tries_x > 0; --tries_x )
4891 {
4892 603869 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4893 603869 try_y = 0;
4894
2/2
✓ Branch 0 taken 586793 times.
✓ Branch 1 taken 603869 times.
1190662 for ( ; tries_y > 0; --tries_y )
4895 {
4896
4/4
✓ Branch 0 taken 591935 times.
✓ Branch 1 taken 11934 times.
✓ Branch 2 taken 587661 times.
✓ Branch 3 taken 4274 times.
1191530 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4897
2/2
✓ Branch 0 taken 568 times.
✓ Branch 1 taken 587093 times.
587661 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4898 603869 try_y += (offgrid ? 8 : 16);
4899
2/2
✓ Branch 0 taken 586793 times.
✓ Branch 1 taken 17076 times.
603869 if (!ok) break;
4900 586793 }
4901
2/2
✓ Branch 0 taken 586793 times.
✓ Branch 1 taken 17076 times.
603869 if (!ok) break;
4902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 586793 times.
586793 if((usehei%16)>0) //Uneven height
4903 {
4904 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4905 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4906 }
4907 586793 try_x += (offgrid ? 8 : 16);
4908 586793 }
4909
2/2
✓ Branch 0 taken 586793 times.
✓ Branch 1 taken 17076 times.
603869 if(!ok) break;
4910
1/2
✓ Branch 0 taken 586793 times.
✗ Branch 1 not taken.
586793 if((usewid%16)>0) //Uneven width
4911 {
4912 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4913 try_y = 0;
4914 for ( ; tries_y > 0; --tries_y )
4915 {
4916 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4917 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4918 try_y += (offgrid ? 8 : 16);
4919 if (!ok) break;
4920 }
4921 if (!ok) break;
4922 if((usehei%16)>0) //Uneven height
4923 {
4924 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4925 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4926 }
4927 }
4928 586793 break;
4929 }
4930 case 15:
4931 case l_up:
4932 {
4933 568437 dx = dx1-s;
4934 568437 dy = dy1-s;
4935 568437 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4936 568437 sv = ((isSideViewGravity())?7:0);
4937
2/2
✓ Branch 0 taken 552494 times.
✓ Branch 1 taken 568437 times.
1120931 for ( ; tries_x > 0; --tries_x )
4938 {
4939 568437 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4940 568437 try_y = 0;
4941
2/2
✓ Branch 0 taken 552494 times.
✓ Branch 1 taken 568437 times.
1120931 for ( ; tries_y > 0; --tries_y )
4942 {
4943
4/4
✓ Branch 0 taken 559771 times.
✓ Branch 1 taken 8666 times.
✓ Branch 2 taken 555802 times.
✓ Branch 3 taken 3969 times.
1124239 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4944
2/2
✓ Branch 0 taken 2439 times.
✓ Branch 1 taken 553363 times.
555802 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4945 568437 try_y += (offgrid ? 8 : 16);
4946
2/2
✓ Branch 0 taken 552494 times.
✓ Branch 1 taken 15943 times.
568437 if (!ok) break;
4947 552494 }
4948
2/2
✓ Branch 0 taken 552494 times.
✓ Branch 1 taken 15943 times.
568437 if (!ok) break;
4949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 552494 times.
552494 if((usehei%16)>0) //Uneven height
4950 {
4951 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4952 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4953 }
4954 552494 try_x += (offgrid ? 8 : 16);
4955 552494 }
4956
2/2
✓ Branch 0 taken 552494 times.
✓ Branch 1 taken 15943 times.
568437 if(!ok) break;
4957
1/2
✓ Branch 0 taken 552494 times.
✗ Branch 1 not taken.
552494 if((usewid%16)>0) //Uneven width
4958 {
4959 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4960 try_y = 0;
4961 for ( ; tries_y > 0; --tries_y )
4962 {
4963 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4964 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4965 try_y += (offgrid ? 8 : 16);
4966 if (!ok) break;
4967 }
4968 if (!ok) break;
4969 if((usehei%16)>0) //Uneven height
4970 {
4971 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4972 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4973 }
4974 }
4975 552494 break;
4976 }
4977 default:
4978 119676 db=99;
4979 119676 return true;
4980 }
4981
4982 7238966 return ok;
4983 7360028 }
4984
4985
4986 4652348 bool enemy::canmove(int32_t ndir,zfix s,int32_t special, bool kb)
4987 {
4988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4652348 times.
4652348 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
4989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4652348 times.
4652348 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4990
1/2
✓ Branch 0 taken 4652348 times.
✗ Branch 1 not taken.
4652348 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
4991
1/2
✓ Branch 0 taken 4652348 times.
✗ Branch 1 not taken.
4652348 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
4992 4652348 --usewid;
4993 4652348 --usehei;
4994 4652348 return canmove(ndir,s,special,0,-8,usewid,usehei,kb);
4995 }
4996
4997 1244902 bool enemy::canmove(int32_t ndir,int32_t special, bool kb)
4998 {
4999 1244902 bool dodongo_move=true; //yes, it's an ugly hack, but we're going to rewrite everything later anyway - DN
5000
5001
4/4
✓ Branch 0 taken 6819 times.
✓ Branch 1 taken 1238083 times.
✓ Branch 2 taken 5021 times.
✓ Branch 3 taken 1798 times.
1244902 if(special==spw_clipright&&ndir==right)
5002 {
5003 1798 dodongo_move=canmove(ndir,(zfix)1,special,0,-8,31,15,kb);
5004 1798 }
5005
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1244897 times.
1244902 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
5006
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1244897 times.
1244902 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
5007
1/2
✓ Branch 0 taken 1244902 times.
✗ Branch 1 not taken.
1244902 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
5008
1/2
✓ Branch 0 taken 1244902 times.
✗ Branch 1 not taken.
1244902 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
5009 1244902 --usewid;
5010 1244902 --usehei;
5011
2/2
✓ Branch 0 taken 717873 times.
✓ Branch 1 taken 527029 times.
1244902 return canmove(ndir,(zfix)1,special,0,-8,usewid,usehei,kb)&&dodongo_move;
5012 }
5013
5014 136347 bool enemy::canmove(int32_t ndir, bool kb)
5015 {
5016 136347 return canmove(ndir,(zfix)1,spw_none,0,-8,15,15,kb);
5017 }
5018
5019 // 8-directional
5020 562 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5021 {
5022 562 int32_t ndir=0;
5023
5024 // can move straight, check if it wants to turn
5025
2/2
✓ Branch 0 taken 549 times.
✓ Branch 1 taken 13 times.
562 if(canmove_old(dir,step,special,dx1,dy1,dx2,dy2))
5026 {
5027
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
549 if(grumble && (zc_oldrand()&4)<grumble) //Homing
5028 {
5029 int32_t w = Lwpns.idFirst(wBait);
5030
5031 if(w>=0)
5032 {
5033 int32_t bx = Lwpns.spr(w)->x;
5034 int32_t by = Lwpns.spr(w)->y;
5035
5036 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5037
5038 if(abs(int32_t(y)-by)>14)
5039 {
5040 if(ndir>0) // Already left or right
5041 {
5042 // Making the diagonal directions
5043 ndir += (by<y) ? 2 : 4;
5044 }
5045 else
5046 {
5047 ndir = (by<y) ? up : down;
5048 }
5049 }
5050
5051 if(canmove(ndir,special,false))
5052 {
5053 dir=ndir;
5054 return;
5055 }
5056 }
5057 }
5058
5059 // Homing added.
5060
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
549 if(newhoming && (zc_oldrand()&255)<newhoming)
5061 {
5062 ndir = lined_up(8,true);
5063
5064 if(ndir>=0 && canmove(ndir,special,false))
5065 {
5066 dir=ndir;
5067 }
5068
5069 return;
5070 }
5071
5072 549 int32_t r=zc_oldrand();
5073
5074
2/4
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 549 times.
549 if(newrate>0 && !(r%newrate))
5075 {
5076 549 ndir = ((dir+((r&64)?-1:1))&7)+8;
5077 549 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5078
5079
2/2
✓ Branch 0 taken 525 times.
✓ Branch 1 taken 24 times.
549 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5080 525 dir=ndir;
5081
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 19 times.
24 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5082 19 dir=ndir2;
5083
5084
3/4
✓ Branch 0 taken 525 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 525 times.
✗ Branch 3 not taken.
549 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5085 // due to numerous lost fractional components. -L
5086 {
5087 x.doFloor();
5088 y.doFloor();
5089 }
5090 549 }
5091
5092 549 return;
5093 }
5094
5095 // can't move straight, must turn
5096 13 int32_t i=0;
5097
5098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 for(; i<32; i++) // Try random dir
5099 {
5100 20 ndir=(zc_oldrand()&7)+8;
5101
5102
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 13 times.
20 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5103 13 break;
5104 7 }
5105
5106
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(i==32)
5107 {
5108 for(ndir=8; ndir<16; ndir++)
5109 {
5110 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5111 goto ok;
5112 }
5113
5114 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5115 }
5116
5117 ok:
5118 13 dir=ndir;
5119 13 x.doFloor();
5120 13 y.doFloor();
5121 562 }
5122
5123 580728 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5124 {
5125 580728 int32_t ndir=0;
5126
5127 // can move straight, check if it wants to turn
5128
2/2
✓ Branch 0 taken 548065 times.
✓ Branch 1 taken 32663 times.
580728 if(canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
5129 {
5130
4/4
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 547858 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 101 times.
548065 if(grumble && (zc_oldrand()&4)<abs(grumble)) //Homing
5131 {
5132 101 int32_t i = Lwpns.idFirst(wBait);
5133
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 if(i >= 0) //idfirst returns -1 if it can't find any
5134 {
5135 weapon *w = (weapon*)Lwpns.spr(i);
5136 if (get_qr(qr_FIND_CLOSEST_BAIT))
5137 {
5138 int32_t currentrange;
5139 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5140 else currentrange = -1;
5141 int curid = i;
5142 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5143 for(; i<Lwpns.Count(); ++i)
5144 {
5145 weapon *lw = (weapon*)Lwpns.spr(i);
5146 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5147 {
5148 currentrange = distance(x, y, lw->x, lw->y);
5149 curid = i;
5150 }
5151 }
5152 i = curid;
5153 if (currentrange == -1) i = -1;
5154 }
5155 else
5156 {
5157 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5158 }
5159 if(i>=0)
5160 {
5161 int32_t bx = Lwpns.spr(i)->x;
5162 int32_t by = Lwpns.spr(i)->y;
5163
5164 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5165
5166 if(abs(int32_t(y)-by)>14)
5167 {
5168 if(ndir>0) // Already left or right
5169 {
5170 // Making the diagonal directions
5171 ndir += (by<y) ? 2 : 4;
5172 }
5173 else
5174 {
5175 ndir = (by<y) ? up : down;
5176 }
5177 }
5178 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5179 if(canmove(ndir,special,false))
5180 {
5181 dir=ndir;
5182 return;
5183 }
5184 }
5185 }
5186 101 }
5187
5188 // Homing added.
5189
4/4
✓ Branch 0 taken 29626 times.
✓ Branch 1 taken 518439 times.
✓ Branch 2 taken 15410 times.
✓ Branch 3 taken 14216 times.
548065 if(newhoming && (zc_oldrand()&255)<abs(newhoming))
5190 {
5191 14216 ndir = lined_up(8,true);
5192
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14216 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14216 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5193
4/4
✓ Branch 0 taken 9445 times.
✓ Branch 1 taken 4771 times.
✓ Branch 2 taken 3593 times.
✓ Branch 3 taken 5852 times.
14216 if(ndir>=0 && canmove(ndir,special,false))
5194 {
5195 5852 dir=ndir;
5196 5852 }
5197
5198 14216 return;
5199 }
5200
5201 533849 int32_t r=zc_oldrand();
5202
5203
4/4
✓ Branch 0 taken 340048 times.
✓ Branch 1 taken 193801 times.
✓ Branch 2 taken 179767 times.
✓ Branch 3 taken 160281 times.
533849 if(newrate>0 && !(r%newrate))
5204 {
5205 160281 ndir = ((dir+((r&64)?-1:1))&7)+8;
5206 160281 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5207
5208
2/2
✓ Branch 0 taken 154477 times.
✓ Branch 1 taken 5804 times.
160281 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5209 154477 dir=ndir;
5210
2/2
✓ Branch 0 taken 857 times.
✓ Branch 1 taken 4947 times.
5804 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5211 4947 dir=ndir2;
5212
5213
4/4
✓ Branch 0 taken 154477 times.
✓ Branch 1 taken 5804 times.
✓ Branch 2 taken 147151 times.
✓ Branch 3 taken 7326 times.
160281 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5214 // due to numerous lost fractional components. -L
5215 {
5216 7326 x.doFloor();
5217 7326 y.doFloor();
5218 7326 }
5219 160281 }
5220
5221 533849 return;
5222 }
5223
5224 // can't move straight, must turn
5225 32663 int32_t i=0;
5226
5227 // TODO: speed this up!
5228
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 61154 times.
61224 for(; i<32; i++) // Try random dir
5229 {
5230 61154 ndir=(zc_oldrand()&7)+8;
5231
5232
2/2
✓ Branch 0 taken 28561 times.
✓ Branch 1 taken 32593 times.
61154 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5233 32593 break;
5234 28561 }
5235
5236
2/2
✓ Branch 0 taken 32593 times.
✓ Branch 1 taken 70 times.
32716 if(i==32)
5237 {
5238
2/2
✓ Branch 0 taken 461 times.
✓ Branch 1 taken 53 times.
514 for(ndir=8; ndir<16; ndir++)
5239 {
5240
2/2
✓ Branch 0 taken 444 times.
✓ Branch 1 taken 17 times.
461 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5241 17 goto ok;
5242 444 }
5243
5244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5245 53 }
5246
5247 ok:
5248 32663 dir=ndir;
5249 32663 x.doFloor();
5250 32663 y.doFloor();
5251 580728 }
5252
5253 574253 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special)
5254 {
5255 574253 newdir_8(newrate,newhoming,special,0,-8,15,15);
5256 574253 }
5257
5258 562 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special)
5259 {
5260 562 newdir_8_old(newrate,newhoming,special,0,-8,15,15);
5261 562 }
5262
5263 // makes the enemy slide backwards when hit
5264 // sclk: first byte is clk, second byte is dir
5265 // makes the enemy slide backwards when hit
5266 // sclk: first byte is clk, second byte is dir
5267 15646054 int32_t enemy::slide()
5268 {
5269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15646054 times.
15646054 if(script_knockback_clk!=0) //scripted knockback
5270 {
5271 sclk = 0;
5272 return 1; //scripted knockback ran
5273 }
5274
5/6
✓ Branch 0 taken 102113 times.
✓ Branch 1 taken 15543941 times.
✓ Branch 2 taken 7857 times.
✓ Branch 3 taken 94256 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7857 times.
15646054 if(sclk==0 || (hp<=0 && !immortal))
5275 15551798 return 0;
5276
5277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94256 times.
94256 if(knockbackflags & FLAG_NOSLIDE)
5278 {
5279 sclk = 0;
5280 if(!OFFGRID_ENEMY)
5281 {
5282 //Fix to grid
5283 do_fix(x, 16, true);
5284 do_fix(y, 16, true);
5285 }
5286 return 0;
5287 }
5288
8/10
✓ Branch 0 taken 9554 times.
✓ Branch 1 taken 84702 times.
✓ Branch 2 taken 298 times.
✓ Branch 3 taken 9256 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 298 times.
✓ Branch 6 taken 7103 times.
✓ Branch 7 taken 2153 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 298 times.
94256 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,0,0,15,15,true)))
5289 {
5290 2153 sclk=0;
5291 2153 return 0;
5292 }
5293
5294 92103 --sclk;
5295
5296
5/5
✓ Branch 0 taken 1785 times.
✓ Branch 1 taken 10539 times.
✓ Branch 2 taken 12291 times.
✓ Branch 3 taken 31734 times.
✓ Branch 4 taken 35754 times.
92103 switch(sclk>>8)
5297 {
5298 case up:
5299 {
5300
4/4
✓ Branch 0 taken 1090 times.
✓ Branch 1 taken 9449 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 10532 times.
10539 if(y<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0))) //vires
5301 {
5302 7 sclk=0;
5303 7 return 0;
5304 }
5305
4/4
✓ Branch 0 taken 1090 times.
✓ Branch 1 taken 9442 times.
✓ Branch 2 taken 915 times.
✓ Branch 3 taken 175 times.
10532 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5306
5307 10357 break;
5308 }
5309 case down:
5310 {
5311
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12289 times.
12291 if(y>=(dmisc2==e2tSPLITHIT ? 150 : 160)) //was 160 --changed for vires bug.
5312 {
5313 2 sclk=0;
5314 2 return 0;
5315 }
5316
4/4
✓ Branch 0 taken 1069 times.
✓ Branch 1 taken 11220 times.
✓ Branch 2 taken 923 times.
✓ Branch 3 taken 146 times.
12289 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5317
5318 12143 break;
5319 }
5320 case left:
5321 {
5322
4/4
✓ Branch 0 taken 2354 times.
✓ Branch 1 taken 29380 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 31721 times.
31734 if(x<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0)))
5323 {
5324 13 sclk=0;
5325 13 return 0;
5326 }
5327
4/4
✓ Branch 0 taken 2354 times.
✓ Branch 1 taken 29367 times.
✓ Branch 2 taken 2116 times.
✓ Branch 3 taken 238 times.
31721 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; }
5328
5329 31483 break;
5330 }
5331 case right:
5332 {
5333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35754 times.
35754 if(x>=(dmisc2==e2tSPLITHIT ? 255 : 240)) //vires
5334 {
5335 sclk=0;
5336 return 0;
5337 }
5338
4/4
✓ Branch 0 taken 3288 times.
✓ Branch 1 taken 32466 times.
✓ Branch 2 taken 3018 times.
✓ Branch 3 taken 270 times.
35754 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5339 35484 break;
5340 }
5341 }
5342
5343 91252 int32_t move = knockbackSpeed;
5344
2/2
✓ Branch 0 taken 86369 times.
✓ Branch 1 taken 91252 times.
177621 while(move>0)
5345 {
5346
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 91252 times.
91252 int32_t thismove = zc_min(8, move);
5347 91252 move -= thismove;
5348 91252 hitdir = (sclk>>8);
5349
5/5
✓ Branch 0 taken 1785 times.
✓ Branch 1 taken 10357 times.
✓ Branch 2 taken 12143 times.
✓ Branch 3 taken 31483 times.
✓ Branch 4 taken 35484 times.
91252 switch(sclk>>8)
5350 {
5351 case up:
5352 10357 y-=thismove;
5353 10357 break;
5354
5355 case down:
5356 12143 y+=thismove;
5357 12143 break;
5358
5359 case left:
5360 31483 x-=thismove;
5361 31483 break;
5362
5363 case right:
5364 35484 x+=thismove;
5365 35484 break;
5366 }
5367
2/2
✓ Branch 0 taken 86369 times.
✓ Branch 1 taken 4883 times.
91252 if(!canmove(sclk>>8,(zfix)0,0,true))
5368 {
5369
3/3
✓ Branch 0 taken 1973 times.
✓ Branch 1 taken 2906 times.
✓ Branch 2 taken 4 times.
4883 switch(sclk>>8)
5370 {
5371 case up:
5372 case down:
5373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1973 times.
1973 if(y < 0)
5374 y = 0;
5375
2/2
✓ Branch 0 taken 325 times.
✓ Branch 1 taken 1648 times.
1973 else if((int32_t(y)&15) > 7)
5376 325 y = TRUNCATE_TILE(int32_t(y)) + 16;
5377 else
5378 1648 y = TRUNCATE_TILE(int32_t(y));
5379
5380 1973 break;
5381
5382 case left:
5383 case right:
5384
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2902 times.
2906 if(x < 0)
5385 4 x = 0;
5386
2/2
✓ Branch 0 taken 833 times.
✓ Branch 1 taken 2069 times.
2902 else if((int32_t(x)&15) > 7)
5387 833 x = TRUNCATE_TILE(int32_t(x)) + 16;
5388 else
5389 2069 x = TRUNCATE_TILE(int32_t(x));
5390
5391 2906 break;
5392 }
5393
5394 4883 sclk=0;
5395 4883 clk3=0;
5396 4883 break;
5397 }
5398 }
5399
5400
2/2
✓ Branch 0 taken 83889 times.
✓ Branch 1 taken 7363 times.
91252 if((sclk&255)==0)
5401 {
5402 //hitdir = -1;
5403 7363 sclk=0;
5404 7363 }
5405 91252 return 2;
5406 15646054 }
5407
5408 bool enemy::can_slide()
5409 {
5410 if(sclk==0 || (hp<=0 && !immortal))
5411 return false;
5412
5413 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,true)))
5414 {
5415 return false;
5416 }
5417
5418 return true;
5419 }
5420
5421 bool enemy::fslide()
5422 {
5423 if(sclk==0 || (hp<=0 && !immortal))
5424 return false;
5425
5426 if((sclk&255)==16 && !canmove(sclk>>8,(zfix)12,spw_floater,true))
5427 {
5428 sclk=0;
5429 return false;
5430 }
5431
5432 --sclk;
5433
5434 switch(sclk>>8)
5435 {
5436 case up:
5437 if(y<=16)
5438 {
5439 sclk=0;
5440 return false;
5441 }
5442
5443 break;
5444
5445 case down:
5446 if(y>=world_h-16)
5447 {
5448 sclk=0;
5449 return false;
5450 }
5451
5452 break;
5453
5454 case left:
5455 if(x<=16)
5456 {
5457 sclk=0;
5458 return false;
5459 }
5460
5461 break;
5462
5463 case right:
5464 if(x>=world_w-16)
5465 {
5466 sclk=0;
5467 return false;
5468 }
5469
5470 break;
5471 }
5472 hitdir = (sclk>>8);
5473 switch(sclk>>8)
5474 {
5475 case up:
5476 y-=4;
5477 break;
5478
5479 case down:
5480 y+=4;
5481 break;
5482
5483 case left:
5484 x-=4;
5485 break;
5486
5487 case right:
5488 x+=4;
5489 break;
5490 }
5491
5492 if(!canmove(sclk>>8,(zfix)0,spw_floater,true))
5493 {
5494 switch(sclk>>8)
5495 {
5496 case up:
5497 case down:
5498 if((int32_t(y)&15) > 7)
5499 y = TRUNCATE_TILE(int32_t(y)) + 16;
5500 else
5501 y = TRUNCATE_TILE(int32_t(y));
5502
5503 break;
5504
5505 case left:
5506 case right:
5507 if((int32_t(x)&15) > 7)
5508 x = TRUNCATE_TILE(int32_t(x)) + 16;
5509 else
5510 x = TRUNCATE_TILE(int32_t(x));
5511
5512 break;
5513 }
5514
5515 sclk=0;
5516 clk3=0;
5517 }
5518
5519 if((sclk&255)==0)
5520 sclk=0;
5521
5522 return true;
5523 }
5524
5525 bool enemy::knockback(int32_t time, int32_t dir, int32_t speed)
5526 {
5527 if((hp<=0 && !immortal)) return false; //No knocking back dead/mid-knockback enemies
5528 if(!canmove(dir,(zfix)speed,0,0,0,15,15,true)) return false; //from slide(); collision check
5529 bool ret = sprite::knockback(time, dir, speed);
5530 if(ret) sclk = 0; //kill engine knockback if interrupted
5531 //! Perhaps also set hitdir here, if needed for timing? -Z
5532 return ret;
5533 }
5534
5535 38009324 bool enemy::runKnockback()
5536 {
5537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38009324 times.
38009324 if((script_knockback_clk&0xFF)==0)
5538 {
5539 38009324 script_knockback_clk = 0;
5540 38009324 return false;
5541 }
5542 if(knockbackflags & FLAG_NOSCRIPTKNOCKBACK)
5543 {
5544 return false;
5545 }
5546 int32_t move = script_knockback_speed;
5547 int32_t kb_dir = script_knockback_clk>>8;
5548 --script_knockback_clk;
5549
5550 while(move>0)
5551 {
5552 int32_t thismove = zc_min(get_qr(qr_OLD_SCRIPTED_KNOCKBACK)?8:4, move);
5553 move -= thismove;
5554 hitdir = kb_dir;
5555 switch(kb_dir)
5556 {
5557 case r_up:
5558 case l_up:
5559 case up:
5560 y-=thismove;
5561 break;
5562
5563 case r_down:
5564 case l_down:
5565 case down:
5566 y+=thismove;
5567 break;
5568 }
5569 switch(kb_dir)
5570 {
5571 case l_up:
5572 case l_down:
5573 case left:
5574 x-=thismove;
5575 break;
5576
5577 case r_up:
5578 case r_down:
5579 case right:
5580 x+=thismove;
5581 break;
5582 }
5583 if (get_qr(qr_OLD_SCRIPTED_KNOCKBACK))
5584 {
5585 if(!canmove(kb_dir,(zfix)0,0,true))
5586 {
5587 script_knockback_clk=0;
5588 clk3=0;
5589 //Fix to grid
5590 switch(kb_dir)
5591 {
5592 case up:
5593 case down:
5594 break;
5595 default:
5596 if(x < 0)
5597 x = 0;
5598 else if((int32_t(x)&15) > 7)
5599 x = TRUNCATE_TILE(int32_t(x)) + 16;
5600 else
5601 x = TRUNCATE_TILE(int32_t(x));
5602 break;
5603 }
5604 switch(kb_dir)
5605 {
5606 case left:
5607 case right:
5608 break;
5609 default:
5610 if(y < 0)
5611 y = 0;
5612 else if((int32_t(y)&15) > 7)
5613 y = TRUNCATE_TILE(int32_t(y)) + 16;
5614 else
5615 y = TRUNCATE_TILE(int32_t(y));
5616 break;
5617 }
5618 break;
5619 }
5620 }
5621 else
5622 {
5623 if(!scr_canplace(x,y,0,true))
5624 {
5625 script_knockback_clk=0;
5626 clk3=0;
5627 //Fix to grid
5628 if (OFFGRID_ENEMY)
5629 {
5630 switch(kb_dir)
5631 {
5632 case up:
5633 case down:
5634 break;
5635 default:
5636 if(x < 0)
5637 x = 0;
5638 else if((int32_t(x)&7) > 3)
5639 x = TRUNCATE_HALF_TILE(int32_t(x)) + 8;
5640 else
5641 x = TRUNCATE_HALF_TILE(int32_t(x));
5642 break;
5643 }
5644 switch(kb_dir)
5645 {
5646 case left:
5647 case right:
5648 break;
5649 default:
5650 if(y < 0)
5651 y = 0;
5652 else if((int32_t(y)&7) > 3)
5653 y = TRUNCATE_HALF_TILE(int32_t(y)) + 8;
5654 else
5655 y = TRUNCATE_HALF_TILE(int32_t(y));
5656 break;
5657 }
5658 }
5659 else
5660 {
5661 switch(kb_dir)
5662 {
5663 case up:
5664 case down:
5665 break;
5666 default:
5667 if(x < 0)
5668 x = 0;
5669 else if((int32_t(x)&15) > 7)
5670 x = TRUNCATE_TILE(int32_t(x)) + 16;
5671 else
5672 x = TRUNCATE_TILE(int32_t(x));
5673 break;
5674 }
5675 switch(kb_dir)
5676 {
5677 case left:
5678 case right:
5679 break;
5680 default:
5681 if(y < 0)
5682 y = 0;
5683 else if((int32_t(y)&15) > 7)
5684 y = TRUNCATE_TILE(int32_t(y)) + 16;
5685 else
5686 y = TRUNCATE_TILE(int32_t(y));
5687 break;
5688 }
5689 }
5690 break;
5691 }
5692
5693 }
5694 }
5695 return true;
5696 38009324 }
5697 // changes enemy's direction, checking restrictions
5698 // rate: 0 = no random changes, 16 = always random change
5699 // homing: 0 = none, 256 = always
5700 // grumble 0 = none, 4 = strongest appetite
5701 521075 void enemy::newdir(int32_t newrate,int32_t newhoming,int32_t special)
5702 {
5703 521075 int32_t ndir=-1;
5704
5705
4/4
✓ Branch 0 taken 110060 times.
✓ Branch 1 taken 411015 times.
✓ Branch 2 taken 37882 times.
✓ Branch 3 taken 72178 times.
521075 if(grumble != 0 && (zc_oldrand()&3)<abs(grumble))
5706 {
5707 72178 int32_t i = Lwpns.idFirst(wBait);
5708
1/2
✓ Branch 0 taken 72178 times.
✗ Branch 1 not taken.
72178 if(i >= 0) //idfirst returns -1 if it can't find any
5709 {
5710 weapon *w = (weapon*)Lwpns.spr(i);
5711 if (get_qr(qr_FIND_CLOSEST_BAIT))
5712 {
5713 int32_t currentrange;
5714 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5715 else currentrange = -1;
5716 int curid = i;
5717 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5718 for(; i<Lwpns.Count(); ++i)
5719 {
5720 weapon *lw = (weapon*)Lwpns.spr(i);
5721 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5722 {
5723 currentrange = distance(x, y, lw->x, lw->y);
5724 curid = i;
5725 }
5726 }
5727 i = curid;
5728 if (currentrange == -1) i = -1;
5729 }
5730 else
5731 {
5732 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5733 }
5734 if (i >= 0)
5735 {
5736 int32_t bx = Lwpns.spr(i)->x;
5737 int32_t by = Lwpns.spr(i)->y;
5738
5739 if(abs(int32_t(y)-by)>14)
5740 {
5741 ndir = (by<y) ? up : down;
5742 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5743 if(canmove(ndir,special,false))
5744 {
5745 dir=ndir;
5746 return;
5747 }
5748 }
5749
5750 ndir = (bx<x) ? left : right;
5751 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5752 if(canmove(ndir,special,false))
5753 {
5754 dir=ndir;
5755 return;
5756 }
5757 }
5758 }
5759 72178 }
5760
5761
2/2
✓ Branch 0 taken 352951 times.
✓ Branch 1 taken 168124 times.
521075 if((zc_oldrand()&255)<abs(newhoming))
5762 {
5763 168124 ndir = lined_up(8,false);
5764
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 168124 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
168124 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5765
4/4
✓ Branch 0 taken 45390 times.
✓ Branch 1 taken 122734 times.
✓ Branch 2 taken 5720 times.
✓ Branch 3 taken 39670 times.
168124 if(ndir>=0 && canmove(ndir,special,false))
5766 {
5767 39670 dir=ndir;
5768 39670 return;
5769 }
5770 128454 }
5771
5772 481405 int32_t i=0;
5773
5774
2/2
✓ Branch 0 taken 3340 times.
✓ Branch 1 taken 1181128 times.
1184468 for(; i<32; i++)
5775 {
5776 1181128 int32_t r=zc_oldrand();
5777
5778
2/2
✓ Branch 0 taken 345129 times.
✓ Branch 1 taken 835999 times.
1181128 if((r&15)<newrate)
5779 345129 ndir=(r>>4)&3;
5780 else
5781 835999 ndir=dir;
5782
5783
2/2
✓ Branch 0 taken 703063 times.
✓ Branch 1 taken 478065 times.
1181128 if(canmove(ndir,special,false))
5784 478065 break;
5785 703063 }
5786
5787
2/2
✓ Branch 0 taken 478065 times.
✓ Branch 1 taken 3340 times.
482163 if(i==32)
5788 {
5789
2/2
✓ Branch 0 taken 8939 times.
✓ Branch 1 taken 758 times.
9697 for(ndir=0; ndir<4; ndir++)
5790 {
5791
2/2
✓ Branch 0 taken 6357 times.
✓ Branch 1 taken 2582 times.
8939 if(canmove(ndir,special,false))
5792 2582 goto ok;
5793 6357 }
5794
5795
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 698 times.
758 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5796 //...Isn't that the point? I'm not sure I understand. Certainly beats phasing through walls... -Dimi
5797 758 }
5798
5799 ok:
5800 481405 dir = ndir;
5801 521075 }
5802
5803 2682 void enemy::newdir()
5804 {
5805 2682 newdir(4,0,spw_none);
5806 2682 }
5807
5808 zfix enemy::distance_left()
5809 {
5810 int32_t a2=x.getInt();
5811 int32_t b2=y.getInt();
5812
5813 switch(dir)
5814 {
5815 case up:
5816 return (zfix)(b2&0xF);
5817
5818 case down:
5819 return (zfix)(16-(b2&0xF));
5820
5821 case left:
5822 return (zfix)(a2&0xF);
5823
5824 case right:
5825 return (zfix)(16-(a2&0xF));
5826 }
5827
5828 return (zfix)0;
5829 }
5830
5831 // keeps walking around
5832 391434 void enemy::constant_walk(int32_t newrate,int32_t newhoming,int32_t special)
5833 {
5834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 391434 times.
391434 if(slide())
5835 return;
5836
5837
8/12
✓ Branch 0 taken 387600 times.
✓ Branch 1 taken 3834 times.
✓ Branch 2 taken 387600 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 383173 times.
✓ Branch 5 taken 4427 times.
✓ Branch 6 taken 383173 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 383173 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 383173 times.
391434 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock )
5838 8261 return;
5839
5840
2/2
✓ Branch 0 taken 26115 times.
✓ Branch 1 taken 357058 times.
383173 if(clk3<=0)
5841 {
5842 26115 fix_coords(true);
5843 26115 newdir(newrate,newhoming,special);
5844
5845
1/2
✓ Branch 0 taken 26115 times.
✗ Branch 1 not taken.
26115 if(step==0)
5846 clk3=0;
5847 else
5848 26115 clk3=int32_t(16.0/step);
5849 26115 }
5850
2/2
✓ Branch 0 taken 357013 times.
✓ Branch 1 taken 45 times.
357058 else if(scored)
5851 {
5852 45 dir^=1;
5853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5854 else clk3=32767;
5855 45 }
5856
5857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383173 times.
383173 if (step != 0) --clk3;
5858 383173 move(step);
5859 391434 }
5860
5861 void enemy::constant_walk()
5862 {
5863 constant_walk(4,0,spw_none);
5864 }
5865
5866 35220 int32_t enemy::pos(int32_t newx,int32_t newy)
5867 {
5868 35220 return (newy<<8)+newx;
5869 }
5870
5871 // for variable step rates
5872 473814 void enemy::variable_walk(int32_t newrate,int32_t newhoming,int32_t special)
5873 {
5874
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 473814 times.
473814 if(slide())
5875 return;
5876
5877
10/14
✓ Branch 0 taken 473814 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 473814 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 465189 times.
✓ Branch 5 taken 8625 times.
✓ Branch 6 taken 455915 times.
✓ Branch 7 taken 9274 times.
✓ Branch 8 taken 418370 times.
✓ Branch 9 taken 37545 times.
✓ Branch 10 taken 418370 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 418370 times.
✗ Branch 13 not taken.
473814 if(clk<0 || dying || stunclk || watch || step == 0 || ceiling || frozenclock )
5878 55444 return;
5879
5880 418370 zfix dx = (zfix)0;
5881 418370 zfix dy = (zfix)0;
5882
5883
5/9
✓ Branch 0 taken 93441 times.
✓ Branch 1 taken 97752 times.
✓ Branch 2 taken 111603 times.
✓ Branch 3 taken 113743 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1831 times.
418370 switch(dir)
5884 {
5885 case 8:
5886 case up:
5887 93441 dy-=step;
5888 93441 break;
5889
5890 case 12:
5891 case down:
5892 97752 dy+=step;
5893 97752 break;
5894
5895 case 14:
5896 case left:
5897 111603 dx-=step;
5898 111603 break;
5899
5900 case 10:
5901 case right:
5902 113743 dx+=step;
5903 113743 break;
5904
5905 case 15:
5906 case l_up:
5907 dx-=step;
5908 dy-=step;
5909 break;
5910
5911 case 9:
5912 case r_up:
5913 dx+=step;
5914 dy-=step;
5915 break;
5916
5917 case 13:
5918 case l_down:
5919 dx-=step;
5920 dy+=step;
5921 break;
5922
5923 case 11:
5924 case r_down:
5925 dx+=step;
5926 dy+=step;
5927 break;
5928 }
5929
5930
8/8
✓ Branch 0 taken 204198 times.
✓ Branch 1 taken 214172 times.
✓ Branch 2 taken 22777 times.
✓ Branch 3 taken 181421 times.
✓ Branch 4 taken 11556 times.
✓ Branch 5 taken 11221 times.
✓ Branch 6 taken 405927 times.
✓ Branch 7 taken 12443 times.
418370 if(((int32_t(x)&15)==0 && (int32_t(y)&15)==0 && clk3!=pos(x,y)) ||
5931 406814 m_walkflag(int32_t(x+dx),int32_t(y+dy), spw_halfstep, dir))
5932 {
5933 12443 fix_coords();
5934 12443 newdir(newrate,newhoming,special);
5935 12443 clk3=pos(x,y);
5936 12443 }
5937
5938 418370 move(step);
5939 473814 }
5940
5941 // pauses for a while after it makes a complete move (to a new square)
5942 12334139 void enemy::halting_walk(int32_t newrate,int32_t newhoming,int32_t special,int32_t newhrate, int32_t haltcnt)
5943 {
5944
4/4
✓ Branch 0 taken 79892 times.
✓ Branch 1 taken 12254247 times.
✓ Branch 2 taken 67060 times.
✓ Branch 3 taken 12832 times.
12334139 if(sclk && clk2)
5945 {
5946 12832 clk3=0;
5947 12832 }
5948
5949
11/14
✓ Branch 0 taken 12261115 times.
✓ Branch 1 taken 73024 times.
✓ Branch 2 taken 12261115 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12261115 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11793947 times.
✓ Branch 7 taken 467168 times.
✓ Branch 8 taken 11656198 times.
✓ Branch 9 taken 137749 times.
✓ Branch 10 taken 11651662 times.
✓ Branch 11 taken 4536 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 11651662 times.
12334139 if(slide() || clk<0 || dying || stunclk || watch || ceiling || frozenclock)
5950 {
5951 682477 return;
5952 }
5953
5954
2/2
✓ Branch 0 taken 2132955 times.
✓ Branch 1 taken 9518707 times.
11651662 if(clk2>0)
5955 {
5956 2132955 --clk2;
5957 2132955 return;
5958 }
5959
5960
2/2
✓ Branch 0 taken 411244 times.
✓ Branch 1 taken 9107463 times.
9518707 if(clk3<=0)
5961 {
5962 411244 fix_coords(true);
5963 411244 newdir(newrate,newhoming,special);
5964 411244 clk3=int32_t(16.0/step);
5965
2/2
✓ Branch 0 taken 411047 times.
✓ Branch 1 taken 197 times.
411244 if (step == 0) clk3 = 32767; //It used to return this in 2.53 and I'm unsure why; I'm guessing dividing by 0 gave max int? Either way, can't be 0 here or scripts break.
5966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 411244 times.
411244 if(clk2<0)
5967 {
5968 clk2=0;
5969 }
5970
2/2
✓ Branch 0 taken 54771 times.
✓ Branch 1 taken 356473 times.
411244 else if((zc_oldrand()&15)<newhrate)
5971 {
5972 54771 clk2=haltcnt;
5973 54771 return;
5974 }
5975 356473 }
5976
2/2
✓ Branch 0 taken 9104303 times.
✓ Branch 1 taken 3160 times.
9107463 else if(scored)
5977 {
5978 3160 dir^=1;
5979
5980
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 3155 times.
3160 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5981 5 else clk3=32767;
5982 3160 }
5983
5984
2/2
✓ Branch 0 taken 76939 times.
✓ Branch 1 taken 9386997 times.
9463936 if (step != 0) --clk3;
5985 9463936 move(step);
5986 12334139 }
5987
5988 // 8-directional movement, aligns to 8 pixels
5989 void enemy::constant_walk_8(int32_t newrate,int32_t newhoming,int32_t special)
5990 {
5991 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
5992 return;
5993
5994 if(clk3<=0)
5995 {
5996 newdir_8(newrate,newhoming,special);
5997 clk3=int32_t(8.0/step);
5998 if (step == 0) clk3 = 32767;
5999 }
6000
6001 if (step != 0) --clk3;
6002 move(step);
6003 }
6004 // 8-directional movement, aligns to 8 pixels
6005 242393 void enemy::constant_walk_8_old(int32_t newrate,int32_t newhoming,int32_t special)
6006 {
6007
6/12
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 242393 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 242393 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 242393 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 242393 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 242393 times.
242393 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6008 return;
6009
6010
2/2
✓ Branch 0 taken 226158 times.
✓ Branch 1 taken 16235 times.
242393 if(clk3<=0)
6011 {
6012 16235 newdir_8(newrate,newhoming,special);
6013 16235 clk3=int32_t(8.0/step);
6014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16235 times.
16235 if (step == 0) clk3 = 32767;
6015 16235 }
6016
6017
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if (step != 0) --clk3;
6018 242393 move(step);
6019 242393 }
6020
6021 void enemy::halting_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t newhrate, int32_t haltcnt)
6022 {
6023 if(clk<0 || dying || stunclk || watch || frozenclock)
6024 return;
6025
6026 if(!canmove(dir,step,special,false))
6027 clk3=0;
6028
6029 if(clk2>0)
6030 {
6031 --clk2;
6032 return;
6033 }
6034
6035 if(clk3<=0)
6036 {
6037 newdir_8(newrate,newhoming,special);
6038 clk3=newclk;
6039
6040 if(clk2<0)
6041 {
6042 clk2=0;
6043 }
6044 else if((zc_oldrand()&15)<newhrate)
6045 {
6046 newdir_8(newrate,newhoming,special);
6047 clk2=haltcnt;
6048 return;
6049 }
6050 }
6051
6052 --clk3;
6053 move(step);
6054 }
6055
6056 // 8-directional movement, no alignment
6057 4721045 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special)
6058 {
6059
9/12
✓ Branch 0 taken 4511760 times.
✓ Branch 1 taken 209285 times.
✓ Branch 2 taken 4511760 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4485139 times.
✓ Branch 5 taken 26621 times.
✓ Branch 6 taken 4474092 times.
✓ Branch 7 taken 11047 times.
✓ Branch 8 taken 4474092 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 4474092 times.
4721045 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6060 246953 return;
6061
6062
2/2
✓ Branch 0 taken 4443604 times.
✓ Branch 1 taken 30488 times.
4474092 if(!canmove(dir,step,special,false))
6063 30488 clk3=0;
6064
6065
2/2
✓ Branch 0 taken 3916074 times.
✓ Branch 1 taken 558018 times.
4474092 if(clk3<=0)
6066 {
6067 558018 newdir_8(newrate,newhoming,special);
6068 558018 clk3=newclk;
6069 558018 }
6070
6071 4474092 --clk3;
6072 4474092 move(step);
6073 4721045 }
6074
6075 // same as above but with variable enemy size
6076 94563 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
6077 {
6078
8/12
✓ Branch 0 taken 93367 times.
✓ Branch 1 taken 1196 times.
✓ Branch 2 taken 93367 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93367 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 93316 times.
✓ Branch 7 taken 51 times.
✓ Branch 8 taken 93316 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 93316 times.
94563 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6079 1247 return;
6080
6081
2/2
✓ Branch 0 taken 91982 times.
✓ Branch 1 taken 1334 times.
93316 if(!canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
6082 1334 clk3=0;
6083
6084
2/2
✓ Branch 0 taken 86841 times.
✓ Branch 1 taken 6475 times.
93316 if(clk3<=0)
6085 {
6086 6475 newdir_8(newrate,newhoming,special,dx1,dy1,dx2,dy2);
6087 6475 clk3=newclk;
6088 6475 }
6089
6090 93316 --clk3;
6091 93316 move(step);
6092 94563 }
6093
6094 // the variable speed floater movement
6095 // ms is max speed
6096 // ss is step speed
6097 // s is step count
6098 // p is pause count
6099 // g is graduality :)
6100 //floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
6101 4019514 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
6102 {
6103 4019514 ++clk2;
6104 4019514 byte over_pit = overpit(this);
6105
6106
4/4
✓ Branch 0 taken 1114794 times.
✓ Branch 1 taken 2904720 times.
✓ Branch 2 taken 1114527 times.
✓ Branch 3 taken 267 times.
4019514 if(dmisc1 && over_pit) p = 0;
6107
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 56650 times.
✓ Branch 2 taken 1586380 times.
✓ Branch 3 taken 2243416 times.
✓ Branch 4 taken 133068 times.
4019514 switch(movestatus)
6108 {
6109 //! This needs a case 4 (landing)....if we want to halt, we move to case 4, and
6110 //! if the conditions prevent it, we jump back to case 2.
6111 case 0: // paused
6112
2/2
✓ Branch 0 taken 55199 times.
✓ Branch 1 taken 1451 times.
56650 if(clk2>=p)
6113 {
6114 1451 movestatus=1;
6115 1451 clk2=0;
6116 1451 }
6117
6118 56650 break;
6119
6120 case 1: // speeding up
6121
1/2
✓ Branch 0 taken 1586380 times.
✗ Branch 1 not taken.
1586380 if (s >= 0)
6122 {
6123
2/2
✓ Branch 0 taken 1575074 times.
✓ Branch 1 taken 11306 times.
1586380 if(clk2<g*s)
6124 {
6125
2/2
✓ Branch 0 taken 1473474 times.
✓ Branch 1 taken 101600 times.
1575074 if(!((clk2-1)%g))
6126 101600 step+=ss;
6127 1575074 }
6128 else
6129 {
6130 11306 movestatus=2;
6131 11306 clk2=0;
6132 }
6133 1586380 }
6134 else
6135 {
6136 if(step < ms)
6137 {
6138 if(!((clk2-1)%g))
6139 {
6140 step+=ss;
6141 if (step >= ms) step = ms;
6142 }
6143 }
6144 else
6145 {
6146 step = ms;
6147 movestatus=2;
6148 clk2=0;
6149 }
6150 }
6151
6152 1586380 break;
6153
6154 case 2: // normal
6155 2243416 step=ms;
6156
6157
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2243416 times.
✓ Branch 2 taken 481019 times.
✓ Branch 3 taken 1762397 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1762397 times.
✓ Branch 6 taken 1760147 times.
✓ Branch 7 taken 2250 times.
2243416 if(clk2>(dmisc15>0?dmisc15:48) && !(zc_oldrand()%(dmisc14>0?dmisc14:768)))
6158 {
6159
1/2
✓ Branch 0 taken 2250 times.
✗ Branch 1 not taken.
2250 if (s >= 0) step=ss*s;
6160 else step=ms;
6161 2250 movestatus=3;
6162 2250 clk2=0;
6163 2250 }
6164
6165 2243416 break;
6166
6167 case 3: // slowing down
6168
1/2
✓ Branch 0 taken 133068 times.
✗ Branch 1 not taken.
133068 if (s >= 0)
6169 {
6170
2/2
✓ Branch 0 taken 131387 times.
✓ Branch 1 taken 1681 times.
133068 if(clk2<=g*s)
6171 {
6172 { //don't slow down over pits
6173
6174
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 131120 times.
131387 if(over_pit)
6175 {
6176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 267 times.
267 if(dmisc1)
6177 {
6178 step=ms;
6179 }
6180 267 }
6181 else //can slow down
6182 {
6183
4/4
✓ Branch 0 taken 8088 times.
✓ Branch 1 taken 123032 times.
✓ Branch 2 taken 7720 times.
✓ Branch 3 taken 368 times.
131120 if(!(clk2%g) && !dmisc1)
6184 7720 step-=ss;
6185 }
6186 }
6187
6188
6189 131387 }
6190 else
6191 {
6192 //if((moveflags&move_can_pitfall)) //don't check pits if the enemy ignores them
6193 //this doesn't help keese, as they have a z of 0.
6194 //they always nee to run this check.
6195 {
6196
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1681 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1681 if(over_pit &&!dmisc1)
6197 {
6198 --clk2; //if over a pit, don't land, and revert clock change
6199 }
6200 else //can land safely
6201 {
6202 1681 movestatus=0;
6203
3/4
✓ Branch 0 taken 1115 times.
✓ Branch 1 taken 566 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1115 times.
1681 if(dmisc1&&!over_pit)
6204 1115 step=0;
6205 1681 clk2=0;
6206 }
6207 }
6208
6209 }
6210 133068 }
6211 else
6212 {
6213 if(step > 0)
6214 {
6215 if(over_pit)
6216 {
6217 if(dmisc1)
6218 {
6219 step=ms;
6220 }
6221 }
6222 else //can slow down
6223 {
6224 if(!(clk2%g))
6225 step-=ss;
6226 }
6227 }
6228 else
6229 {
6230 //if((moveflags&move_can_pitfall)) //don't check pits if the enemy ignores them
6231 //this doesn't help keese, as they have a z of 0.
6232 //they always nee to run this check.
6233 if(over_pit)
6234 {
6235 step+=ss; //if over a pit, don't land, and revert clock change
6236 }
6237 else //can land safely
6238 {
6239 movestatus=0;
6240 step=0;
6241 clk2=0;
6242 }
6243 }
6244 }
6245
6246 133068 break;
6247 }
6248
6249
2/2
✓ Branch 0 taken 2252472 times.
✓ Branch 1 taken 1767042 times.
4019514 variable_walk_8(movestatus==2?newrate:0,homing,newclk,spw_floater);
6250 4019514 }
6251
6252 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix s)
6253 {
6254 floater_walk(newrate,newclk,s,(zfix)0.125,3,80,32);
6255 }
6256
6257 // Checks if enemy is lined up with Hero. If so, returns direction Hero is
6258 // at as compared to enemy. Returns -1 if not lined up. Range is inclusive.
6259 927949 int32_t enemy::lined_up(int32_t range, bool dir8)
6260 {
6261 927949 int32_t lx = Hero.getX();
6262 927949 int32_t ly = Hero.getY();
6263
6264
2/2
✓ Branch 0 taken 38914 times.
✓ Branch 1 taken 889035 times.
927949 if(abs(lx-int32_t(x))<=range)
6265 {
6266
2/2
✓ Branch 0 taken 16351 times.
✓ Branch 1 taken 22563 times.
38914 if(ly<y)
6267 {
6268 16351 return up;
6269 }
6270
6271 22563 return down;
6272 }
6273
6274
2/2
✓ Branch 0 taken 56361 times.
✓ Branch 1 taken 832674 times.
889035 if(abs(ly-int32_t(y))<=range)
6275 {
6276
2/2
✓ Branch 0 taken 30301 times.
✓ Branch 1 taken 26060 times.
56361 if(lx<x)
6277 {
6278 30301 return left;
6279 }
6280
6281 26060 return right;
6282 }
6283
6284
2/2
✓ Branch 0 taken 160084 times.
✓ Branch 1 taken 672590 times.
832674 if(dir8)
6285 {
6286
2/2
✓ Branch 0 taken 253848 times.
✓ Branch 1 taken 418742 times.
672590 if(abs(lx-x)-abs(ly-y)<=range)
6287 //if(abs(lx-x)-abs(ly-y)<=range && abs(ly-y)-abs(lx-x)<=range) //Fix floating enemies not seeking hero. -Tamamo
6288 {
6289
2/2
✓ Branch 0 taken 106080 times.
✓ Branch 1 taken 147768 times.
253848 if(ly<y)
6290 {
6291
2/2
✓ Branch 0 taken 56676 times.
✓ Branch 1 taken 49404 times.
106080 if(lx<x)
6292 {
6293 56676 return l_up;
6294 }
6295 else
6296 {
6297 49404 return r_up;
6298 }
6299 }
6300 else
6301 {
6302
2/2
✓ Branch 0 taken 76696 times.
✓ Branch 1 taken 71072 times.
147768 if(lx<x)
6303 {
6304 71072 return l_down;
6305 }
6306 else
6307 {
6308 76696 return r_down;
6309 }
6310 }
6311 }
6312 418742 }
6313
6314 578826 return -1;
6315 927949 }
6316
6317 // returns true if Hero is within 'range' pixels of the enemy
6318 27884 bool enemy::HeroInRange(int32_t range)
6319 {
6320 27884 int32_t lx = Hero.getX();
6321 27884 int32_t ly = Hero.getY();
6322
2/2
✓ Branch 0 taken 22775 times.
✓ Branch 1 taken 5109 times.
27884 return abs(lx-int32_t(x))<=range && abs(ly-int32_t(y))<=range;
6323 }
6324
6325 // place the enemy in line with Hero (red wizzrobes)
6326 4899 void enemy::place_on_axis(bool floater, bool solid_ok)
6327 {
6328
6/6
✓ Branch 0 taken 587 times.
✓ Branch 1 taken 4312 times.
✓ Branch 2 taken 4355 times.
✓ Branch 3 taken 544 times.
✓ Branch 4 taken 587 times.
✓ Branch 5 taken 3768 times.
4899 int32_t lx=zc_min(zc_max(int32_t(Hero.getX())&0xF0,32),208);
6329
6/6
✓ Branch 0 taken 439 times.
✓ Branch 1 taken 4460 times.
✓ Branch 2 taken 4109 times.
✓ Branch 3 taken 790 times.
✓ Branch 4 taken 439 times.
✓ Branch 5 taken 3670 times.
4899 int32_t ly=zc_min(zc_max(int32_t(Hero.getY())&0xF0,32),128);
6330 4899 int32_t pos2=zc_oldrand()%23;
6331 4899 int32_t tried=0;
6332 4899 bool last_resort,placed=false;
6333
6334
6335 4899 do
6336 {
6337
2/2
✓ Branch 0 taken 4460 times.
✓ Branch 1 taken 3127 times.
7587 if(pos2<14)
6338 {
6339 4460 x=(pos2<<4)+16;
6340 4460 y=ly;
6341 4460 }
6342 else
6343 {
6344 3127 x=lx;
6345 3127 y=((pos2-14)<<4)+16;
6346 }
6347
6348 // Don't commit to a last resort if position is out of bounds.
6349
6/6
✓ Branch 0 taken 7248 times.
✓ Branch 1 taken 339 times.
✓ Branch 2 taken 6936 times.
✓ Branch 3 taken 312 times.
✓ Branch 4 taken 257 times.
✓ Branch 5 taken 6679 times.
7587 last_resort= !(x<32 || y<32 || x>=224 || y>=144);
6350
6351
4/4
✓ Branch 0 taken 3907 times.
✓ Branch 1 taken 3680 times.
✓ Branch 2 taken 4862 times.
✓ Branch 3 taken 1287 times.
7587 if(abs(lx-int32_t(x))>16 || abs(ly-int32_t(y))>16)
6352 {
6353 // Red Wizzrobes should be able to appear on water, but not other
6354 // solid combos; however, they could appear on solid combos in 2.10,
6355 // and some quests depend on that.
6356
4/4
✓ Branch 0 taken 2341 times.
✓ Branch 1 taken 6201 times.
✓ Branch 2 taken 1302 times.
✓ Branch 3 taken 4899 times.
8542 if((solid_ok || !m_walkflag(x,y,floater ? spw_water : spw_door, dir))
6357 8542 && !flyerblocked(x,y,floater ? spw_floater : spw_door))
6358 4899 placed=true;
6359 8542 }
6360
6361
3/6
✓ Branch 0 taken 2688 times.
✓ Branch 1 taken 4537 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2688 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7225 if(!placed && tried>=22 && last_resort)
6362 {
6363 placed=true;
6364 }
6365
6366 7225 ++tried;
6367 7225 pos2=(pos2+3)%23;
6368
2/2
✓ Branch 0 taken 2688 times.
✓ Branch 1 taken 4537 times.
7225 }
6369 7225 while(!placed);
6370
6371
2/2
✓ Branch 0 taken 2729 times.
✓ Branch 1 taken 1808 times.
4537 if(y==ly)
6372 2729 dir=(x<lx)?right:left;
6373 else
6374 1808 dir=(y<ly)?down:up;
6375
6376 4537 clk2=tried;
6377 4537 }
6378
6379 20335203 int32_t enemy::n_frame_n_dir(int32_t frames, int32_t ndir, int32_t f4)
6380 {
6381 20335203 int32_t t = o_tile;
6382 20335203 int32_t b = o_tile;
6383
6384 // Darknuts, but also Wizzrobes and Wallmasters
6385
3/4
✓ Branch 0 taken 8417552 times.
✓ Branch 1 taken 10877881 times.
✓ Branch 2 taken 1039770 times.
✗ Branch 3 not taken.
20335203 switch(type)
6386 {
6387 case eeWALK:
6388
5/6
✓ Branch 0 taken 505407 times.
✓ Branch 1 taken 10372474 times.
✓ Branch 2 taken 367468 times.
✓ Branch 3 taken 137939 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 367468 times.
10877881 if(dmisc9==e9tPOLSVOICE && clk2>=0 && do_animation)
6389 {
6390 367468 tile=s_tile;
6391 367468 t=s_tile;
6392 367468 b=s_tile;
6393 367468 }
6394
6395 10877881 break;
6396
6397 case eeTRAP:
6398
4/6
✓ Branch 0 taken 193566 times.
✓ Branch 1 taken 846204 times.
✓ Branch 2 taken 193566 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 193566 times.
1039770 if(dummy_int[1] && guysbuf[id].flags & guy_trp2 && do_animation) // Just to make sure
6399 {
6400 193566 tile=s_tile;
6401 193566 t=s_tile;
6402 193566 b=s_tile;
6403 193566 }
6404
6405 1039770 break;
6406
6407 case eeSPINTILE:
6408 if(misc>=96 && do_animation)
6409 {
6410 tile=o_tile+frames*ndir;
6411 t=tile;
6412 }
6413
6414 break;
6415 }
6416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20335203 times.
20335203 if ( do_animation )
6417 {
6418
4/6
✓ Branch 0 taken 197042 times.
✓ Branch 1 taken 20138161 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 267131 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 19871030 times.
20335203 if(ndir!=0) switch(frames)
6419 {
6420 case 2:
6421 267131 tiledir_small(dir,ndir==4);
6422 267131 break;
6423
6424 case 3:
6425 tiledir_three(dir);
6426 break;
6427
6428 case 4:
6429 19871030 tiledir(dir,ndir==4);
6430 19871030 break;
6431 20138161 }
6432
6433
2/2
✓ Branch 0 taken 10877881 times.
✓ Branch 1 taken 9457322 times.
20335203 if(type==eeWALK)
6434
6/6
✓ Branch 0 taken 10816559 times.
✓ Branch 1 taken 61322 times.
✓ Branch 2 taken 8211621 times.
✓ Branch 3 taken 2666260 times.
✓ Branch 4 taken 2650448 times.
✓ Branch 5 taken 15812 times.
10877881 tile=zc_min(tile+f4, t+frames*(zc_max(dir, 0)+1)-1);
6435 else
6436 9457322 tile+=f4;
6437 20335203 }
6438 20335203 return b;
6439 }
6440
6441 void enemy::tiledir_three(int32_t ndir)
6442 {
6443 if ( !do_animation ) return;
6444 flip=0;
6445
6446 switch(ndir)
6447 {
6448 case right:
6449 tile+=3;
6450 [[fallthrough]];
6451
6452 case left:
6453 tile+=3;
6454 [[fallthrough]];
6455
6456 case down:
6457 tile+=3;
6458 [[fallthrough]];
6459
6460 case up:
6461 break;
6462 }
6463 }
6464
6465 267131 void enemy::tiledir_small(int32_t ndir, bool fourdir)
6466 {
6467
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 267131 times.
267131 if ( !do_animation ) return;
6468 267131 flip=0;
6469
6470
8/9
✓ Branch 0 taken 53829 times.
✓ Branch 1 taken 54679 times.
✓ Branch 2 taken 67727 times.
✓ Branch 3 taken 71182 times.
✓ Branch 4 taken 5706 times.
✓ Branch 5 taken 5154 times.
✓ Branch 6 taken 4872 times.
✓ Branch 7 taken 3982 times.
✗ Branch 8 not taken.
267131 switch(ndir)
6471 {
6472 case 8:
6473 case up:
6474 53829 break;
6475
6476 case 12:
6477 case down:
6478 54679 tile+=2;
6479 54679 break;
6480
6481 case 14:
6482 case left:
6483 67727 tile+=4;
6484 67727 break;
6485
6486 case 10:
6487 case right:
6488 71182 tile+=6;
6489 71182 break;
6490
6491 case 9:
6492 case r_up:
6493
1/2
✓ Branch 0 taken 5706 times.
✗ Branch 1 not taken.
5706 if(fourdir)
6494 5706 break;
6495
6496 tile+=10;
6497 break;
6498
6499 case 11:
6500 case r_down:
6501
1/2
✓ Branch 0 taken 5154 times.
✗ Branch 1 not taken.
5154 if(fourdir)
6502 5154 tile+=2;
6503 else
6504 tile+=14;
6505
6506 5154 break;
6507
6508 case 13:
6509 case l_down:
6510
1/2
✓ Branch 0 taken 4872 times.
✗ Branch 1 not taken.
4872 if(fourdir)
6511 4872 tile+=2;
6512 else
6513 tile+=12;
6514
6515 4872 break;
6516
6517 case 15:
6518 case l_up:
6519
1/2
✓ Branch 0 taken 3982 times.
✗ Branch 1 not taken.
3982 if(fourdir)
6520 3982 break;
6521
6522 tile+=8;
6523 break;
6524
6525 default:
6526 //dir=(zc_oldrand()*100)%8;
6527 //tiledir_small(dir);
6528 // flip=zc_oldrand()&3;
6529 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6530 break;
6531 }
6532 267131 }
6533
6534 23203778 void enemy::tiledir(int32_t ndir, bool fourdir)
6535 {
6536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23203778 times.
23203778 if ( !do_animation ) return;
6537 23203778 flip=0;
6538
6539
9/9
✓ Branch 0 taken 4509460 times.
✓ Branch 1 taken 4163442 times.
✓ Branch 2 taken 5444983 times.
✓ Branch 3 taken 5198041 times.
✓ Branch 4 taken 834140 times.
✓ Branch 5 taken 1027612 times.
✓ Branch 6 taken 1106457 times.
✓ Branch 7 taken 852481 times.
✓ Branch 8 taken 67162 times.
23203778 switch(ndir)
6540 {
6541 case 8:
6542 case up:
6543 4509460 break;
6544
6545 case 12:
6546 case down:
6547 4163442 tile+=4;
6548 4163442 break;
6549
6550 case 14:
6551 case left:
6552 5444983 tile+=8;
6553 5444983 break;
6554
6555 case 10:
6556 case right:
6557 5198041 tile+=12;
6558 5198041 break;
6559
6560 case 9:
6561 case r_up:
6562
2/2
✓ Branch 0 taken 89257 times.
✓ Branch 1 taken 744883 times.
834140 if(fourdir)
6563 89257 break;
6564 else
6565 744883 tile+=24;
6566
6567 744883 break;
6568
6569 case 11:
6570 case r_down:
6571
2/2
✓ Branch 0 taken 102657 times.
✓ Branch 1 taken 924955 times.
1027612 if(fourdir)
6572 102657 tile+=4;
6573 else
6574 924955 tile+=32;
6575
6576 1027612 break;
6577
6578 case 13:
6579 case l_down:
6580
2/2
✓ Branch 0 taken 106171 times.
✓ Branch 1 taken 1000286 times.
1106457 if(fourdir)
6581 106171 tile+=4;
6582 else
6583 1000286 tile+=28;
6584
6585 1106457 break;
6586
6587 case 15:
6588 case l_up:
6589
2/2
✓ Branch 0 taken 82882 times.
✓ Branch 1 taken 769599 times.
852481 if(fourdir)
6590 82882 break;
6591 else
6592 769599 tile+=20;
6593
6594 769599 break;
6595
6596 default:
6597 //dir=(zc_oldrand()*100)%8;
6598 //tiledir(dir);
6599 // flip=zc_oldrand()&3;
6600 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6601 67162 break;
6602 }
6603 23203778 }
6604
6605 3868 void enemy::tiledir_big(int32_t ndir, bool fourdir)
6606 {
6607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if ( !do_animation ) return;
6608 3868 flip=0;
6609
6610
7/9
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✓ Branch 3 taken 179 times.
✓ Branch 4 taken 306 times.
✓ Branch 5 taken 1235 times.
✓ Branch 6 taken 1324 times.
✓ Branch 7 taken 332 times.
✗ Branch 8 not taken.
3868 switch(ndir)
6611 {
6612 case 8:
6613 case up:
6614 297 break;
6615
6616 case 12:
6617 case down:
6618 tile+=8;
6619 break;
6620
6621 case 14:
6622 case left:
6623 195 tile+=40;
6624 195 break;
6625
6626 case 10:
6627 case right:
6628 179 tile+=48;
6629 179 break;
6630
6631 case 9:
6632 case r_up:
6633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 306 times.
306 if(fourdir)
6634 break;
6635
6636 306 tile+=88;
6637 306 break;
6638
6639 case 11:
6640 case r_down:
6641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1235 times.
1235 if(fourdir)
6642 tile+=8;
6643 else
6644 1235 tile+=128;
6645
6646 1235 break;
6647
6648 case 13:
6649 case l_down:
6650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1324 times.
1324 if(fourdir)
6651 tile+=8;
6652 else
6653 1324 tile+=120;
6654
6655 1324 break;
6656
6657 case 15:
6658 case l_up:
6659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
332 if(fourdir)
6660 break;
6661
6662 332 tile+=80;
6663 332 break;
6664
6665 default:
6666 //dir=(zc_oldrand()*100)%8;
6667 //tiledir_big(dir);
6668 // flip=zc_oldrand()&3;
6669 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6670 break;
6671 }
6672 3868 }
6673
6674 40162690 void enemy::update_enemy_frame()
6675 {
6676
4/4
✓ Branch 0 taken 40160315 times.
✓ Branch 1 taken 2375 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 40160308 times.
40162690 if(fallclk||drownclk) return;
6677
1/2
✓ Branch 0 taken 40160308 times.
✗ Branch 1 not taken.
40160308 if (!do_animation)
6678 return;
6679
6680
4/4
✓ Branch 0 taken 1549487 times.
✓ Branch 1 taken 38610821 times.
✓ Branch 2 taken 1547480 times.
✓ Branch 3 taken 2007 times.
40160308 if (get_qr(qr_OLD_TILE_INITIALIZATION) || tile == 0) tile = o_tile; //tile was initialized here before. It needs to be initialized here as well.
6681
6682
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
40160308 if(get_qr(qr_ANONE_NOANIM)
6683
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 40160308 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
40160308 && anim == aNONE && type != eeGUY)
6684 return;
6685
2/2
✓ Branch 0 taken 371376 times.
✓ Branch 1 taken 39788932 times.
40160308 int32_t newfrate = zc_max(frate,4);
6686 40160308 int32_t f4=abs(clk/(newfrate/4)); // casts clk to [0,1,2,3]
6687 40160308 int32_t f2=abs(clk/(newfrate/2)); // casts clk to [0,1]
6688
2/2
✓ Branch 0 taken 30164014 times.
✓ Branch 1 taken 9996294 times.
40160308 int32_t fx = get_qr(qr_NEWENEMYTILES) ? f4 : f2;
6689 40160308 tile = o_tile;
6690 40160308 int32_t basetile = o_tile;
6691 40160308 int32_t tilerows = 1; // How many rows of tiles? The Extend code needs to know.
6692 40160308 bool ignore_extend = false;
6693
35/40
✓ Branch 0 taken 220021 times.
✓ Branch 1 taken 8628 times.
✓ Branch 2 taken 209083 times.
✓ Branch 3 taken 1755010 times.
✓ Branch 4 taken 363745 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 140514 times.
✓ Branch 7 taken 366633 times.
✓ Branch 8 taken 836734 times.
✓ Branch 9 taken 3868 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 5096784 times.
✓ Branch 12 taken 69324 times.
✓ Branch 13 taken 53456 times.
✓ Branch 14 taken 38833 times.
✓ Branch 15 taken 455374 times.
✓ Branch 16 taken 1525813 times.
✓ Branch 17 taken 197042 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 128880 times.
✓ Branch 20 taken 221637 times.
✓ Branch 21 taken 693272 times.
✓ Branch 22 taken 1694695 times.
✓ Branch 23 taken 1134909 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 267131 times.
✓ Branch 26 taken 4134724 times.
✓ Branch 27 taken 7515986 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 582937 times.
✓ Branch 30 taken 1178979 times.
✓ Branch 31 taken 880176 times.
✓ Branch 32 taken 219096 times.
✓ Branch 33 taken 1818304 times.
✓ Branch 34 taken 133344 times.
✓ Branch 35 taken 1433 times.
✓ Branch 36 taken 7018408 times.
✓ Branch 37 taken 747030 times.
✓ Branch 38 taken 276997 times.
✓ Branch 39 taken 171508 times.
40160308 switch(anim)
6694 {
6695
6696 case aDONGO:
6697 {
6698 69324 int32_t fr = stunclk>0 ? 16 : 8;
6699
6700
6/6
✓ Branch 0 taken 67426 times.
✓ Branch 1 taken 1898 times.
✓ Branch 2 taken 6720 times.
✓ Branch 3 taken 60706 times.
✓ Branch 4 taken 2240 times.
✓ Branch 5 taken 4480 times.
69324 if(!dying && clk2>0 && clk2<=64)
6701 {
6702 // bloated
6703
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 960 times.
✓ Branch 2 taken 960 times.
✓ Branch 3 taken 1664 times.
✓ Branch 4 taken 896 times.
4480 switch(dir)
6704 {
6705 case up:
6706 960 tile+=9;
6707 960 flip=0;
6708 960 xofs=0;
6709 960 dummy_int[1]=0; //no additional tiles
6710 960 break;
6711
6712 case down:
6713 960 tile+=7;
6714 960 flip=0;
6715 960 xofs=0;
6716 960 dummy_int[1]=0; //no additional tiles
6717 960 break;
6718
6719 case left:
6720 1664 flip=1;
6721 1664 tile+=4;
6722 1664 xofs=16;
6723 1664 dummy_int[1]=1; //second tile is next tile
6724 1664 break;
6725
6726 case right:
6727 896 flip=0;
6728 896 tile+=5;
6729 896 xofs=16;
6730 896 dummy_int[1]=-1; //second tile is previous tile
6731 896 break;
6732 }
6733 4480 }
6734
4/4
✓ Branch 0 taken 1898 times.
✓ Branch 1 taken 62946 times.
✓ Branch 2 taken 781 times.
✓ Branch 3 taken 1117 times.
64844 else if(!dying || clk2>19)
6735 {
6736 // normal
6737
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 13652 times.
✓ Branch 2 taken 15374 times.
✓ Branch 3 taken 19615 times.
✓ Branch 4 taken 15086 times.
63727 switch(dir)
6738 {
6739 case up:
6740 13652 tile+=8;
6741 13652 flip=(clk&fr)?1:0;
6742 13652 xofs=0;
6743 13652 dummy_int[1]=0; //no additional tiles
6744 13652 break;
6745
6746 case down:
6747 15374 tile+=6;
6748 15374 flip=(clk&fr)?1:0;
6749 15374 xofs=0;
6750 15374 dummy_int[1]=0; //no additional tiles
6751 15374 break;
6752
6753 case left:
6754 19615 flip=1;
6755 19615 tile+=(clk&fr)?2:0;
6756 19615 xofs=16;
6757 19615 dummy_int[1]=1; //second tile is next tile
6758 19615 break;
6759
6760 case right:
6761 15086 flip=0;
6762 15086 tile+=(clk&fr)?3:1;
6763 15086 xofs=16;
6764 15086 dummy_int[1]=-1; //second tile is next tile
6765 15086 break;
6766 }
6767 63727 }
6768 }
6769 69324 break;
6770
6771 case aNEWDONGO:
6772 {
6773 53456 int32_t fr4=0;
6774
6775
6/6
✓ Branch 0 taken 51564 times.
✓ Branch 1 taken 1892 times.
✓ Branch 2 taken 4128 times.
✓ Branch 3 taken 47436 times.
✓ Branch 4 taken 1376 times.
✓ Branch 5 taken 2752 times.
53456 if(!dying && clk2>0 && clk2<=64)
6776 {
6777 // bloated
6778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2752 times.
2752 if(clk2>=0)
6779 {
6780 2752 fr4=3;
6781 2752 }
6782
6783
2/2
✓ Branch 0 taken 645 times.
✓ Branch 1 taken 2107 times.
2752 if(clk2>=16)
6784 {
6785 2107 fr4=2;
6786 2107 }
6787
6788
2/2
✓ Branch 0 taken 1333 times.
✓ Branch 1 taken 1419 times.
2752 if(clk2>=32)
6789 {
6790 1419 fr4=1;
6791 1419 }
6792
6793
2/2
✓ Branch 0 taken 2021 times.
✓ Branch 1 taken 731 times.
2752 if(clk2>=48)
6794 {
6795 731 fr4=0;
6796 731 }
6797
6798
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 704 times.
✓ Branch 4 taken 1216 times.
2752 switch(dir)
6799 {
6800 case up:
6801 256 xofs=0;
6802 256 tile+=8+fr4;
6803 256 dummy_int[1]=0; //no additional tiles
6804 256 break;
6805
6806 case down:
6807 576 xofs=0;
6808 576 tile+=12+fr4;
6809 576 dummy_int[1]=0; //no additional tiles
6810 576 break;
6811
6812 case left:
6813 704 tile+=29+(2*fr4);
6814 704 xofs=16;
6815 704 dummy_int[1]=-1; //second tile is previous tile
6816 704 break;
6817
6818 case right:
6819 1216 tile+=49+(2*fr4);
6820 1216 xofs=16;
6821 1216 dummy_int[1]=-1; //second tile is previous tile
6822 1216 break;
6823 }
6824 2752 }
6825
4/4
✓ Branch 0 taken 1892 times.
✓ Branch 1 taken 48812 times.
✓ Branch 2 taken 994 times.
✓ Branch 3 taken 898 times.
50704 else if(!dying || clk2>19)
6826 {
6827 // normal
6828
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 9234 times.
✓ Branch 2 taken 9871 times.
✓ Branch 3 taken 15025 times.
✓ Branch 4 taken 15676 times.
49806 switch(dir)
6829 {
6830 case up:
6831 9234 xofs=0;
6832 9234 tile+=((clk&12)>>2);
6833 9234 dummy_int[1]=0; //no additional tiles
6834 9234 break;
6835
6836 case down:
6837 9871 xofs=0;
6838 9871 tile+=4+((clk&12)>>2);
6839 9871 dummy_int[1]=0; //no additional tiles
6840 9871 break;
6841
6842 case left:
6843 15025 tile+=21+((clk&12)>>1);
6844 15025 xofs=16;
6845 15025 dummy_int[1]=-1; //second tile is previous tile
6846 15025 break;
6847
6848 case right:
6849 15676 flip=0;
6850 15676 tile+=41+((clk&12)>>1);
6851 15676 xofs=16;
6852 15676 dummy_int[1]=-1; //second tile is previous tile
6853 15676 break;
6854 }
6855 49806 }
6856 }
6857 53456 break;
6858
6859 case aDONGOBS:
6860 {
6861 38833 int32_t fr4=0;
6862
6863
6/6
✓ Branch 0 taken 37675 times.
✓ Branch 1 taken 1158 times.
✓ Branch 2 taken 4032 times.
✓ Branch 3 taken 33643 times.
✓ Branch 4 taken 1344 times.
✓ Branch 5 taken 2688 times.
38833 if(!dying && clk2>0 && clk2<=64)
6864 {
6865 // bloated
6866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2688 times.
2688 if(clk2>=0)
6867 {
6868 2688 fr4=3;
6869 2688 }
6870
6871
2/2
✓ Branch 0 taken 630 times.
✓ Branch 1 taken 2058 times.
2688 if(clk2>=16)
6872 {
6873 2058 fr4=2;
6874 2058 }
6875
6876
2/2
✓ Branch 0 taken 1302 times.
✓ Branch 1 taken 1386 times.
2688 if(clk2>=32)
6877 {
6878 1386 fr4=1;
6879 1386 }
6880
6881
2/2
✓ Branch 0 taken 1974 times.
✓ Branch 1 taken 714 times.
2688 if(clk2>=48)
6882 {
6883 714 fr4=0;
6884 714 }
6885
6886
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 384 times.
✓ Branch 3 taken 1024 times.
✓ Branch 4 taken 1024 times.
2688 switch(dir)
6887 {
6888 case up:
6889 256 tile+=28+fr4;
6890 256 yofs+=8;
6891 256 dummy_int[1]=-20; //second tile change
6892 256 dummy_int[2]=0; //new xofs change
6893 256 dummy_int[3]=-16; //new xofs change
6894 256 break;
6895
6896 case down:
6897 384 tile+=12+fr4;
6898 384 yofs-=8;
6899 384 dummy_int[1]=20; //second tile change
6900 384 dummy_int[2]=0; //new xofs change
6901 384 dummy_int[3]=16; //new xofs change
6902 384 break;
6903
6904 case left:
6905 1024 tile+=49+(2*fr4);
6906 1024 xofs+=8;
6907 1024 dummy_int[1]=-1; //second tile change
6908 1024 dummy_int[2]=-16; //new xofs change
6909 1024 dummy_int[3]=0; //new xofs change
6910 1024 break;
6911
6912 case right:
6913 1024 tile+=69+(2*fr4);
6914 1024 xofs+=8;
6915 1024 dummy_int[1]=-1; //second tile change
6916 1024 dummy_int[2]=-16; //new xofs change
6917 1024 dummy_int[3]=0; //new xofs change
6918 1024 break;
6919 }
6920 2688 }
6921
4/4
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 34987 times.
✓ Branch 2 taken 497 times.
✓ Branch 3 taken 661 times.
36145 else if(!dying || clk2>19)
6922 {
6923 // normal
6924
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 7136 times.
✓ Branch 2 taken 6672 times.
✓ Branch 3 taken 11075 times.
✓ Branch 4 taken 10601 times.
35484 switch(dir)
6925 {
6926 case up:
6927 7136 tile+=20+((clk&24)>>3);
6928 7136 yofs+=8;
6929 7136 dummy_int[1]=-20; //second tile change
6930 7136 dummy_int[2]=0; //new xofs change
6931 7136 dummy_int[3]=-16; //new xofs change
6932 7136 break;
6933
6934 case down:
6935 6672 tile+=4+((clk&24)>>3);
6936 6672 yofs-=8;
6937 6672 dummy_int[1]=20; //second tile change
6938 6672 dummy_int[2]=0; //new xofs change
6939 6672 dummy_int[3]=16; //new xofs change
6940 6672 break;
6941
6942 case left:
6943 11075 xofs=-8;
6944 11075 tile+=40+((clk&24)>>2);
6945 11075 dummy_int[1]=1; //second tile change
6946 11075 dummy_int[2]=16; //new xofs change
6947 11075 dummy_int[3]=0; //new xofs change
6948 11075 break;
6949
6950 case right:
6951 10601 tile+=60+((clk&24)>>2);
6952 10601 xofs=-8;
6953 10601 dummy_int[1]=1; //second tile change
6954 10601 dummy_int[2]=16; //new xofs change
6955 10601 dummy_int[3]=0; //new xofs change
6956 10601 break;
6957 }
6958 35484 }
6959 }
6960 38833 break;
6961
6962 case aWIZZ:
6963 {
6964 // if(d->misc1)
6965
2/2
✓ Branch 0 taken 182184 times.
✓ Branch 1 taken 273190 times.
455374 if(dmisc1)
6966 {
6967
2/2
✓ Branch 0 taken 91057 times.
✓ Branch 1 taken 91127 times.
182184 if(clk&8)
6968 {
6969 91127 ++tile;
6970 91127 }
6971 182184 }
6972 else
6973 {
6974
2/2
✓ Branch 0 taken 136701 times.
✓ Branch 1 taken 136489 times.
273190 if(frame&4)
6975 {
6976 136489 ++tile;
6977 136489 }
6978 }
6979
6980
4/4
✓ Branch 0 taken 76094 times.
✓ Branch 1 taken 157108 times.
✓ Branch 2 taken 145581 times.
✓ Branch 3 taken 76591 times.
455374 switch(dir)
6981 {
6982 case 9:
6983 case 15:
6984 case up:
6985 76094 tile+=2;
6986 76094 break;
6987
6988 case down:
6989 76591 break;
6990
6991 case 13:
6992 case left:
6993 157108 flip=1;
6994 157108 break;
6995
6996 default:
6997 145581 flip=0;
6998 145581 break;
6999 }
7000 }
7001 455374 break;
7002
7003 case aNEWWIZZ:
7004 {
7005 1525813 tiledir(dir,true);
7006
7007 // if(d->misc1) //walking wizzrobe
7008
2/2
✓ Branch 0 taken 742424 times.
✓ Branch 1 taken 783389 times.
1525813 if(dmisc1) //walking wizzrobe
7009 {
7010
2/2
✓ Branch 0 taken 373321 times.
✓ Branch 1 taken 369103 times.
742424 if(clk&8)
7011 {
7012 369103 tile+=2;
7013 369103 }
7014
7015
2/2
✓ Branch 0 taken 372085 times.
✓ Branch 1 taken 370339 times.
742424 if(clk&4)
7016 {
7017 370339 tile+=1;
7018 370339 }
7019
7020
2/4
✓ Branch 0 taken 742424 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 742424 times.
742424 if(!(dummy_bool[1]||dummy_bool[2])) //should never be charging or firing for these wizzrobes
7021 {
7022
2/2
✓ Branch 0 taken 663262 times.
✓ Branch 1 taken 79162 times.
742424 if(dummy_int[1]>0)
7023 {
7024 79162 tile+=40;
7025 79162 }
7026 742424 }
7027 742424 }
7028 else
7029 {
7030
4/4
✓ Branch 0 taken 716244 times.
✓ Branch 1 taken 67145 times.
✓ Branch 2 taken 168827 times.
✓ Branch 3 taken 547417 times.
783389 if(dummy_bool[1]||dummy_bool[2])
7031 {
7032 235972 tile+=20;
7033
7034
2/2
✓ Branch 0 taken 67136 times.
✓ Branch 1 taken 168836 times.
235972 if(dummy_bool[2])
7035 {
7036 168836 tile+=20;
7037 168836 }
7038 235972 }
7039
7040 783389 tile+=((frame>>1)&3);
7041 }
7042 }
7043 1525813 break;
7044
7045 case a3FRM:
7046 {
7047
2/2
✓ Branch 0 taken 46675 times.
✓ Branch 1 taken 150367 times.
197042 basetile = n_frame_n_dir(3, 0, (f4==3) ? 1 : f4);
7048 }
7049 197042 break;
7050
7051 case a3FRM4DIR:
7052 {
7053 basetile = n_frame_n_dir(3, 4, (f4==3) ? 1 : f4);
7054 }
7055 break;
7056
7057 case aVIRE:
7058 {
7059
2/2
✓ Branch 0 taken 99588 times.
✓ Branch 1 taken 29292 times.
128880 if(dir==up)
7060 {
7061 29292 tile+=2;
7062 29292 }
7063
7064 128880 tile+=fx;
7065 }
7066 128880 break;
7067
7068 case aROPE:
7069 {
7070 220021 tile+=(1-fx);
7071 220021 flip = dir==left ? 1:0;
7072 }
7073 220021 break;
7074
7075 case aZORA:
7076 {
7077 int32_t dl;
7078
7079
2/2
✓ Branch 0 taken 46739 times.
✓ Branch 1 taken 174898 times.
221637 if(clk<36)
7080 {
7081 46739 dl=clk+5;
7082 46739 goto waves2;
7083 }
7084
7085
2/2
✓ Branch 0 taken 82440 times.
✓ Branch 1 taken 92458 times.
174898 if(clk<36+66)
7086
2/2
✓ Branch 0 taken 50715 times.
✓ Branch 1 taken 31725 times.
82440 tile=(dir==up)?o_tile+1:o_tile;
7087 else
7088 {
7089 92458 dl=clk-36-66;
7090 waves2:
7091 139197 tile=((dl/11)&1)+s_tile;
7092 139197 basetile = s_tile;
7093 }
7094 }
7095 221637 break;
7096
7097 case aNEWZORA:
7098 {
7099 693272 f4=(clk/16)%4;
7100
7101 693272 tiledir(dir,true);
7102 int32_t dl;
7103
7104
4/4
✓ Branch 0 taken 489980 times.
✓ Branch 1 taken 203292 times.
✓ Branch 2 taken 251304 times.
✓ Branch 3 taken 238676 times.
693272 if((clk>35)&&(clk<36+67)) //surfaced
7105 {
7106
4/4
✓ Branch 0 taken 204043 times.
✓ Branch 1 taken 34633 times.
✓ Branch 2 taken 29458 times.
✓ Branch 3 taken 174585 times.
238676 if((clk>=(35+10))&&(clk<(38+56))) //mouth open
7107 {
7108 174585 tile+=80;
7109 174585 } //mouth closed
7110 else
7111 {
7112 64091 tile+=40;
7113 }
7114
7115 238676 tile+=f4;
7116 238676 }
7117 else
7118 {
7119
2/2
✓ Branch 0 taken 203292 times.
✓ Branch 1 taken 251304 times.
454596 if(clk<36)
7120 {
7121 203292 dl=clk+5;
7122 203292 }
7123 else
7124 {
7125 251304 dl=clk-36-66;
7126 }
7127
7128 454596 tile+=((dl/5)&3);
7129 }
7130 }
7131 693272 break;
7132
7133 case a4FRM4EYE:
7134 case a2FRM4EYE:
7135 case a4FRM8EYE:
7136 case a4FRM8EYEB: //big version
7137 case a4FRM4EYEB:
7138 {
7139 836734 tilerows = 2;
7140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 836734 times.
836734 int fakex = x + 8*(zc_max(1,txsz)-1);
7141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 836734 times.
836734 int fakey = y + 8*(zc_max(1,tysz)-1);
7142 double _MSVC2022_tmp1, _MSVC2022_tmp2;
7143 836734 double ddir=atan2_MSVC2022_FIX(double(fakey-(Hero.y)),double(Hero.x-fakex));
7144 836734 int32_t lookat=zc_oldrand()&15;
7145
7146
4/4
✓ Branch 0 taken 272091 times.
✓ Branch 1 taken 564643 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 210774 times.
836734 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
7147 {
7148 210774 lookat=l_down;
7149 210774 }
7150
4/4
✓ Branch 0 taken 288167 times.
✓ Branch 1 taken 337793 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 226850 times.
625960 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
7151 {
7152 226850 lookat=down;
7153 226850 }
7154
4/4
✓ Branch 0 taken 170154 times.
✓ Branch 1 taken 228956 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 108837 times.
399110 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
7155 {
7156 108837 lookat=r_down;
7157 108837 }
7158
4/4
✓ Branch 0 taken 131712 times.
✓ Branch 1 taken 158561 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 70395 times.
290273 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
7159 {
7160 70395 lookat=right;
7161 70395 }
7162
4/4
✓ Branch 0 taken 96384 times.
✓ Branch 1 taken 123494 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 35067 times.
219878 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
7163 {
7164 35067 lookat=r_up;
7165 35067 }
7166
4/4
✓ Branch 0 taken 86753 times.
✓ Branch 1 taken 98058 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 25436 times.
184811 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
7167 {
7168 25436 lookat=up;
7169 25436 }
7170
4/4
✓ Branch 0 taken 98120 times.
✓ Branch 1 taken 61255 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 36803 times.
159375 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
7171 {
7172 36803 lookat=l_up;
7173 36803 }
7174 else
7175 {
7176 122572 lookat=left;
7177 }
7178
7179 836734 int32_t dir2 = dir;
7180 836734 dir = lookat;
7181
3/6
✓ Branch 0 taken 836734 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 836734 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 836734 times.
836734 if (anim != a4FRM8EYEB && anim != a4FRM4EYEB) basetile = n_frame_n_dir(anim==a2FRM4EYE ? 2:4, anim==a4FRM8EYE ? 8 : 4, anim==a2FRM4EYE ? (f2&1):f4);
7182 else
7183 {
7184 tiledir_big(dir,(anim == a4FRM4EYEB));
7185 tile+=2*f4;
7186 ignore_extend = true;
7187 }
7188 836734 dir = dir2;
7189 }
7190 836734 break;
7191
7192 case aFLIP:
7193 {
7194 1694695 flip = f2&1;
7195 }
7196 1694695 break;
7197
7198 case a2FRM:
7199 {
7200 1134909 tile += (1-f2);
7201 }
7202 1134909 break;
7203
7204 case a2FRMB:
7205 {
7206 tile+= 2*(1-f2);
7207 ignore_extend = true;
7208 }
7209 break;
7210
7211 case a2FRM4DIR:
7212 {
7213 267131 basetile = n_frame_n_dir(2, 4, f2&1);
7214 }
7215 267131 break;
7216
7217 case a4FRM4DIRF:
7218 {
7219 4134724 basetile = n_frame_n_dir(4,4,f4);
7220
7221
2/2
✓ Branch 0 taken 2733716 times.
✓ Branch 1 taken 1401008 times.
4134724 if(clk2>0) //stopped to fire
7222 {
7223 1401008 tile+=20;
7224
7225
2/2
✓ Branch 0 taken 698282 times.
✓ Branch 1 taken 702726 times.
1401008 if(clk2<17) //firing
7226 {
7227 702726 tile+=20;
7228 702726 }
7229 1401008 }
7230 }
7231 4134724 break;
7232
7233 case a4FRM4DIR:
7234 {
7235 7515986 basetile = n_frame_n_dir(4,4,f4);
7236 }
7237 7515986 break;
7238
7239 case a4FRM8DIRF:
7240 {
7241 tilerows = 2;
7242 basetile = n_frame_n_dir(4,8,f4);
7243
7244 if(clk2>0) //stopped to fire
7245 {
7246 tile+=40;
7247
7248 if(clk2<17) //firing
7249 {
7250 tile+=40;
7251 }
7252 }
7253 }
7254 break;
7255
7256 case a4FRM8DIRB:
7257 case a4FRM8DIRFB:
7258 {
7259 3868 tilerows = 2;
7260 3868 tiledir_big(dir,false);
7261 3868 tile+=2*f4;
7262
3/4
✓ Branch 0 taken 3866 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3866 times.
✗ Branch 3 not taken.
3868 if(clk2>0 && anim == a4FRM8DIRFB) //stopped to fire
7263 {
7264 tile+=80;
7265
7266 if(clk2<17) //firing
7267 {
7268 tile+=80;
7269 }
7270 }
7271 3868 ignore_extend = true;
7272 }
7273 3868 break;
7274
7275 case a4FRM4DIRB:
7276 case a4FRM4DIRFB:
7277 {
7278 tilerows = 2;
7279 tiledir_big(dir,true);
7280 tile+=2*f4;
7281 if(clk2>0 && anim == a4FRM4DIRFB) //stopped to fire
7282 {
7283 tile+=40;
7284
7285 if(clk2<17) //firing
7286 {
7287 tile+=40;
7288 }
7289 }
7290 ignore_extend = true;
7291 }
7292 break;
7293
7294 case aOCTO:
7295 {
7296
5/5
✓ Branch 0 taken 4152 times.
✓ Branch 1 taken 122459 times.
✓ Branch 2 taken 133448 times.
✓ Branch 3 taken 165651 times.
✓ Branch 4 taken 157227 times.
582937 switch(dir)
7297 {
7298 case up:
7299 122459 flip = 2;
7300 122459 break;
7301
7302 case down:
7303 133448 flip = 0;
7304 133448 break;
7305
7306 case left:
7307 165651 flip = 0;
7308 165651 tile += 2;
7309 165651 break;
7310
7311 case right:
7312 157227 flip = 1;
7313 157227 tile += 2;
7314 157227 break;
7315 }
7316
7317 582937 tile+=f2;
7318 }
7319 582937 break;
7320
7321 case aWALK:
7322 {
7323
5/5
✓ Branch 0 taken 5614 times.
✓ Branch 1 taken 248704 times.
✓ Branch 2 taken 267165 times.
✓ Branch 3 taken 331694 times.
✓ Branch 4 taken 325802 times.
1178979 switch(dir)
7324 {
7325 case up:
7326 248704 tile+=3;
7327 248704 flip = f2;
7328 248704 break;
7329
7330 case down:
7331 267165 tile+=2;
7332 267165 flip = f2;
7333 267165 break;
7334
7335 case left:
7336 331694 flip=1;
7337 331694 tile += f2;
7338 331694 break;
7339
7340 case right:
7341 325802 flip=0;
7342 325802 tile += f2;
7343 325802 break;
7344 }
7345 }
7346 1178979 break;
7347
7348 case aDWALK:
7349 {
7350
3/4
✓ Branch 0 taken 92330 times.
✓ Branch 1 taken 787846 times.
✓ Branch 2 taken 92330 times.
✗ Branch 3 not taken.
880176 if((get_qr(qr_BRKNSHLDTILES)) && (dummy_bool[1]==true))
7351 {
7352 tile=s_tile;
7353 basetile = s_tile;
7354 }
7355
7356
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 177728 times.
✓ Branch 2 taken 185581 times.
✓ Branch 3 taken 260885 times.
✓ Branch 4 taken 255982 times.
880176 switch(dir)
7357 {
7358 case up:
7359 177728 tile+=2;
7360 177728 flip=f2;
7361 177728 break;
7362
7363 case down:
7364 185581 flip=0;
7365 185581 tile+=(1-f2);
7366 185581 break;
7367
7368 case left:
7369 260885 flip=1;
7370 260885 tile+=(3+f2);
7371 260885 break;
7372
7373 case right:
7374 255982 flip=0;
7375 255982 tile+=(3+f2);
7376 255982 break;
7377 }
7378 }
7379 880176 break;
7380
7381 case aTEK:
7382 {
7383
2/2
✓ Branch 0 taken 139976 times.
✓ Branch 1 taken 79120 times.
219096 if(misc==0)
7384 {
7385 79120 tile += f2;
7386 79120 }
7387
2/2
✓ Branch 0 taken 73149 times.
✓ Branch 1 taken 66827 times.
139976 else if(misc!=1)
7388 {
7389 66827 ++tile;
7390 66827 }
7391 }
7392 219096 break;
7393
7394 case aNEWTEK:
7395 {
7396
2/2
✓ Branch 0 taken 475246 times.
✓ Branch 1 taken 1343058 times.
1818304 if(step<0) //up
7397 {
7398
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 235369 times.
✓ Branch 2 taken 239877 times.
475246 switch(clk3)
7399 {
7400 case left:
7401 235369 flip=0;
7402 235369 tile+=20;
7403 235369 break;
7404
7405 case right:
7406 239877 flip=0;
7407 239877 tile+=24;
7408 239877 break;
7409 }
7410 475246 }
7411
2/2
✓ Branch 0 taken 54749 times.
✓ Branch 1 taken 1288309 times.
1343058 else if(step==0)
7412 {
7413
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 40566 times.
✓ Branch 2 taken 14183 times.
54749 switch(clk3)
7414 {
7415 case left:
7416 40566 flip=0;
7417 40566 tile+=8;
7418 40566 break;
7419
7420 case right:
7421 14183 flip=0;
7422 14183 tile+=12;
7423 14183 break;
7424 }
7425 54749 } //down
7426 else
7427 {
7428
3/3
✓ Branch 0 taken 109149 times.
✓ Branch 1 taken 593340 times.
✓ Branch 2 taken 585820 times.
1288309 switch(clk3)
7429 {
7430 case left:
7431 593340 flip=0;
7432 593340 tile+=28;
7433 593340 break;
7434
7435 case right:
7436 585820 flip=0;
7437 585820 tile+=32;
7438 585820 break;
7439 }
7440 }
7441
7442
2/2
✓ Branch 0 taken 1238755 times.
✓ Branch 1 taken 579549 times.
1818304 if(misc==0)
7443 {
7444 579549 tile+=f4;
7445 579549 }
7446
2/2
✓ Branch 0 taken 582085 times.
✓ Branch 1 taken 656670 times.
1238755 else if(misc!=1)
7447 {
7448 656670 tile+=2;
7449 656670 }
7450 }
7451 1818304 break;
7452
7453 case aARMOS:
7454 {
7455
2/2
✓ Branch 0 taken 3227 times.
✓ Branch 1 taken 5401 times.
8628 if(!fading)
7456 {
7457 5401 tile += fx;
7458
7459
2/2
✓ Branch 0 taken 4204 times.
✓ Branch 1 taken 1197 times.
5401 if(dir==up)
7460 1197 tile += 2;
7461 5401 }
7462 }
7463 8628 break;
7464
7465 case aARMOS4:
7466 {
7467
5/5
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 29165 times.
✓ Branch 2 taken 92624 times.
✓ Branch 3 taken 43654 times.
✓ Branch 4 taken 43190 times.
209083 switch(dir)
7468 {
7469 case up:
7470 29165 flip=0;
7471 29165 break;
7472
7473 case down:
7474 92624 flip=0;
7475 92624 tile+=4;
7476 92624 break;
7477
7478 case left:
7479 43654 flip=0;
7480 43654 tile+=8;
7481 43654 break;
7482
7483 case right:
7484 43190 flip=0;
7485 43190 tile+=12;
7486 43190 break;
7487 }
7488
7489
2/2
✓ Branch 0 taken 63155 times.
✓ Branch 1 taken 145928 times.
209083 if(!fading)
7490 {
7491 145928 tile+=f4;
7492 145928 }
7493 }
7494 209083 break;
7495
7496 case aGHINI:
7497 {
7498
4/4
✓ Branch 0 taken 28037 times.
✓ Branch 1 taken 32092 times.
✓ Branch 2 taken 72763 times.
✓ Branch 3 taken 452 times.
133344 switch(dir)
7499 {
7500 case 8:
7501 case 9:
7502 case up:
7503 28037 ++tile;
7504 28037 flip=0;
7505 28037 break;
7506
7507 case 15:
7508 452 ++tile;
7509 452 flip=1;
7510 452 break;
7511
7512 case 10:
7513 case 11:
7514 case right:
7515 32092 flip=1;
7516 32092 break;
7517
7518 default:
7519 72763 flip=0;
7520 72763 break;
7521 }
7522 }
7523 133344 break;
7524
7525 case a2FRMPOS:
7526 {
7527 1755010 tile+=posframe;
7528 }
7529 1755010 break;
7530
7531 case a4FRMPOS4DIR:
7532 {
7533 363745 basetile = n_frame_n_dir(4,4,0);
7534 // tile+=f2;
7535 363745 tile+=posframe;
7536 }
7537 363745 break;
7538
7539 case a4FRMPOS4DIRF:
7540 {
7541 1433 basetile = n_frame_n_dir(4,4,0);
7542
7543
2/2
✓ Branch 0 taken 1236 times.
✓ Branch 1 taken 197 times.
1433 if(clk2>0) //stopped to fire
7544 {
7545 197 tile+=20;
7546
7547
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 64 times.
197 if(clk2<17) //firing
7548 {
7549 64 tile+=20;
7550 64 }
7551 197 }
7552
7553 // tile+=f2;
7554 1433 tile+=posframe;
7555 }
7556 1433 break;
7557
7558 case a4FRMPOS8DIR:
7559 {
7560 7018408 tilerows = 2;
7561 7018408 int32_t n = tile;
7562 7018408 basetile = n_frame_n_dir(4,8,0);
7563 // tile+=f2;
7564 7018408 tile+=posframe;
7565 }
7566 7018408 break;
7567
7568 case a4FRMPOS8DIRF:
7569 {
7570 tilerows = 2;
7571 basetile = n_frame_n_dir(4,8,0);
7572
7573 if(clk2>0) //stopped to fire
7574 {
7575 tile+=40;
7576
7577 if(clk2<17) //firing
7578 {
7579 tile+=40;
7580 }
7581 }
7582
7583 tile+=posframe;
7584 }
7585 break;
7586
7587 case aNEWLEV:
7588 {
7589 747030 tiledir(dir,true);
7590
7591
4/5
✓ Branch 0 taken 258994 times.
✓ Branch 1 taken 115368 times.
✓ Branch 2 taken 48980 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 323688 times.
747030 switch(misc)
7592 {
7593 case -1:
7594 case 0:
7595 258994 return;
7596
7597 case 1:
7598
7599 // case 5: cs = d->misc2; break;
7600 case 5:
7601 115368 cs = dmisc2;
7602 115368 break;
7603
7604 case 2:
7605 case 4:
7606 48980 tile += 20;
7607 48980 break;
7608
7609 case 3:
7610 323688 tile += 40;
7611 323688 break;
7612 }
7613
7614 488036 tile+=f4;
7615 }
7616 488036 break;
7617
7618 case aLEV:
7619 {
7620 276997 f4 = ((clk/5)&1);
7621
7622
4/5
✓ Branch 0 taken 127945 times.
✓ Branch 1 taken 33336 times.
✓ Branch 2 taken 14658 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 101058 times.
276997 switch(misc)
7623 {
7624 case -1:
7625 case 0:
7626 127945 return;
7627
7628 case 1:
7629
7630 // case 5: tile += (f2) ? 1 : 0; cs = d->misc2; break;
7631 case 5:
7632 33336 tile += (f2) ? 1 : 0;
7633 33336 cs = dmisc2;
7634 33336 break;
7635
7636 case 2:
7637 case 4:
7638 14658 tile += 2;
7639 14658 break;
7640
7641 case 3:
7642 101058 tile += (f4) ? 4 : 3;
7643 101058 break;
7644 }
7645 }
7646 149052 break;
7647
7648 case aWALLM:
7649 {
7650
2/2
✓ Branch 0 taken 750 times.
✓ Branch 1 taken 139764 times.
140514 if(!dummy_bool[1])
7651 {
7652 139764 tile += f2;
7653 139764 }
7654 }
7655 140514 break;
7656
7657 case aNEWWALLM:
7658 {
7659 366633 int32_t tempdir=0;
7660
7661
4/4
✓ Branch 0 taken 38855 times.
✓ Branch 1 taken 43340 times.
✓ Branch 2 taken 8438 times.
✓ Branch 3 taken 276000 times.
366633 switch(misc)
7662 {
7663 case 1:
7664 case 2:
7665 43340 tempdir=clk3;
7666 43340 break;
7667
7668 case 3:
7669 case 4:
7670 case 5:
7671 38855 tempdir=dir;
7672 38855 break;
7673
7674 case 6:
7675 case 7:
7676 8438 tempdir=clk3^1;
7677 8438 break;
7678 }
7679
7680 366633 tiledir(tempdir,true);
7681
7682
2/2
✓ Branch 0 taken 1908 times.
✓ Branch 1 taken 364725 times.
366633 if(!dummy_bool[1])
7683 {
7684 364725 tile+=f4;
7685 364725 }
7686 }
7687 366633 break;
7688
7689 case a4FRMNODIR:
7690 {
7691 171508 tile+=f4;
7692 }
7693 171508 break;
7694
7695 } // switch(d->anim)
7696
7697 // flashing
7698 // if(d->flags & guy_flashing)
7699
2/2
✓ Branch 0 taken 39025820 times.
✓ Branch 1 taken 747549 times.
39773369 if(flags & guy_flashing)
7700 {
7701 747549 cs = (frame&3) + 6;
7702 747549 }
7703
7704
2/2
✓ Branch 0 taken 39362421 times.
✓ Branch 1 taken 410948 times.
39773369 if(flags&guy_transparent)
7705 {
7706 410948 drawstyle=1;
7707 410948 }
7708
7709 39773369 int32_t change = tile-basetile;
7710
7711
3/6
✓ Branch 0 taken 2054943 times.
✓ Branch 1 taken 37718426 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2054943 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
39773369 if(extend > 2 && (!ignore_extend || get_qr(qr_BROKEN_BIG_ENEMY_ANIMATION)))
7712 {
7713
2/2
✓ Branch 0 taken 1792915 times.
✓ Branch 1 taken 262028 times.
2054943 if(basetile/TILES_PER_ROW==(basetile+((txsz*change)/tilerows))/TILES_PER_ROW)
7714 {
7715 1792915 tile=basetile+txsz*change;
7716 1792915 }
7717 else
7718 {
7719 262028 tile=basetile+(txsz*change)+((tysz-1)*TILES_PER_ROW)*(((basetile+txsz*change)/TILES_PER_ROW)-(basetile/TILES_PER_ROW));
7720 }
7721 2054943 }
7722 else
7723 {
7724 37718426 tile=basetile+change;
7725 }
7726 40162690 }
7727
7728 81117 int32_t enemy::wpnsfx(int32_t wpn)
7729 {
7730
3/3
✓ Branch 0 taken 22419 times.
✓ Branch 1 taken 40991 times.
✓ Branch 2 taken 17707 times.
81117 switch (wpn)
7731 {
7732 case wScript1:
7733 case wScript2:
7734 case wScript3:
7735 case wScript4:
7736 case wScript5:
7737 case wScript6:
7738 case wScript7:
7739 case wScript8:
7740 case wScript9:
7741 case wScript10: //sure why not
7742 case ewFireTrail:
7743 case ewFlame:
7744 case ewFlame2Trail:
7745 case ewFlame2:
7746 case ewWind:
7747 case ewMagic:
7748 case ewIce:
7749 22419 return firesfx;
7750
7751 case ewRock:
7752 case ewFireball2:
7753 case ewFireball:
7754
2/2
✓ Branch 0 taken 5533 times.
✓ Branch 1 taken 35458 times.
40991 if (get_qr(qr_MORESOUNDS)) return firesfx;
7755 35458 break;
7756 }
7757
7758 53165 return 0;
7759 81117 }
7760
7761 77044177 int32_t enemy::run_script(int32_t mode)
7762 {
7763 void push_ri();
7764 void pop_ri();
7765
7766
3/4
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 77043921 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 256 times.
77044177 if(switch_hooked && !get_qr(qr_SWITCHOBJ_RUN_SCRIPT)) return RUNSCRIPT_OK;
7767
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 77043921 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
77043921 if (script <= 0 || FFCore.getQuestHeaderInfo(vZelda) < 0x255 || FFCore.system_suspend[susptNPCSCRIPTS])
7768 77043921 return RUNSCRIPT_OK;
7769 auto scrty = *get_scrtype();
7770 auto uid = getUID();
7771 if(!FFCore.doscript(scrty,uid))
7772 return RUNSCRIPT_OK;
7773 int32_t ret = RUNSCRIPT_OK;
7774 bool& waitdraw = FFCore.waitdraw(scrty, uid);
7775 push_ri();
7776 switch(mode)
7777 {
7778 case MODE_NORMAL:
7779 ret = ZScriptVersion::RunScript(ScriptType::NPC, script, uid);
7780 break;
7781
7782 case MODE_WAITDRAW:
7783 if(waitdraw)
7784 {
7785 ret = ZScriptVersion::RunScript(ScriptType::NPC, script, uid);
7786 waitdraw = false;
7787 }
7788 break;
7789 }
7790 pop_ri();
7791 return ret;
7792 77044177 }
7793 ALLEGRO_COLOR enemy::hitboxColor(byte opacity) const
7794 {
7795 return al_map_rgba(255,0,0,opacity);
7796 }
7797
7798 // good guys, fires, fairy, and other non-enemies
7799 // based on enemy class b/c guys in dungeons act sort of like enemies
7800 // also easier to manage all the guys this way
7801 2191 guy::guy(zfix X,zfix Y,int32_t Id,int32_t Clk,bool mg) : enemy(X,Y,Id,Clk)
7802 2191 {
7803 2191 mainguy=mg;
7804 2191 canfreeze=false;
7805 2191 dir=down;
7806
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2191 times.
✓ Branch 2 taken 2191 times.
✗ Branch 3 not taken.
2191 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
7807 2191 hxofs=2;
7808 2191 hzsz=8;
7809 2191 hit_width=12;
7810 2191 hit_height=17;
7811
7812
10/12
✓ Branch 0 taken 2191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2191 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 765 times.
✓ Branch 5 taken 1426 times.
✓ Branch 6 taken 743 times.
✓ Branch 7 taken 22 times.
✓ Branch 8 taken 276 times.
✓ Branch 9 taken 467 times.
✓ Branch 10 taken 16 times.
✓ Branch 11 taken 260 times.
2191 if(!superman && (!isdungeon(screen_spawned) || id==gFAIRY || id==gFIRE || id==gZELDA))
7813 {
7814 1931 superman = 1;
7815 1931 hxofs=1000;
7816 1931 }
7817 2191 }
7818
7819 943762 bool guy::animate(int32_t index)
7820 {
7821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 943762 times.
943762 if(switch_hooked) return enemy::animate(index);
7822
6/6
✓ Branch 0 taken 543192 times.
✓ Branch 1 taken 400570 times.
✓ Branch 2 taken 8298 times.
✓ Branch 3 taken 534894 times.
✓ Branch 4 taken 7092 times.
✓ Branch 5 taken 1206 times.
943762 if(mainguy && clk==0 && misc==0)
7823 {
7824 1206 setupscreen();
7825 1206 misc = 1;
7826 1206 }
7827
7828
4/4
✓ Branch 0 taken 543192 times.
✓ Branch 1 taken 400570 times.
✓ Branch 2 taken 542862 times.
✓ Branch 3 taken 330 times.
943762 if(mainguy && fadeclk==0)
7829 330 return true;
7830
7831 943432 hp=256; // good guys never die...
7832
7833
4/4
✓ Branch 0 taken 922 times.
✓ Branch 1 taken 942510 times.
✓ Branch 2 taken 906 times.
✓ Branch 3 taken 16 times.
943432 if(hclk && !clk2)
7834 {
7835 // but if they get hit...
7836 16 ++clk2; // only do this once
7837
7838
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 7 times.
16 if(!get_qr(qr_NOGUYFIRES))
7839 {
7840 7 addenemy(screen_spawned,BSZ?64:72,68,eSHOOTFBALL,0);
7841 7 addenemy(screen_spawned,BSZ?176:168,68,eSHOOTFBALL,0);
7842 7 }
7843 16 }
7844
7845 943432 return enemy::animate(index);
7846 943762 }
7847
7848 947535 void guy::draw(BITMAP *dest)
7849 {
7850 947535 update_enemy_frame();
7851
7852
6/6
✓ Branch 0 taken 546756 times.
✓ Branch 1 taken 400779 times.
✓ Branch 2 taken 22911 times.
✓ Branch 3 taken 523845 times.
✓ Branch 4 taken 11064 times.
✓ Branch 5 taken 11847 times.
947535 if(!mainguy || fadeclk<0 || fadeclk&1)
7853 935688 enemy::draw(dest);
7854 947535 }
7855
7856 760 eFire::eFire(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7857 760 {
7858 760 clk4=0;
7859
4/8
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 760 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 760 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 760 times.
✗ Branch 7 not taken.
760 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
7860 // Spawn type
7861
2/4
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 760 times.
760 if(flags & guy_fade_flicker)
7862 {
7863 clk=0;
7864 superman = 1;
7865 fading=fade_flicker;
7866 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7867 dir=down;
7868
7869 if(!canmove(down,(zfix)8,spw_none,false))
7870 clk3=int32_t(13.0/step);
7871 }
7872
3/4
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 676 times.
✓ Branch 3 taken 84 times.
760 else if(flags & guy_fade_instant)
7873 {
7874 84 clk=0;
7875 84 }
7876
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
760 if (SIZEflags != 0) init_size_flags();;
7877 760 }
7878
7879 167472 bool eFire::animate(int32_t index)
7880 {
7881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 167472 times.
167472 if(switch_hooked) return enemy::animate(index);
7882
2/4
✓ Branch 0 taken 167472 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 167472 times.
167472 if(fallclk||drownclk) return enemy::animate(index);
7883
2/2
✓ Branch 0 taken 165756 times.
✓ Branch 1 taken 1716 times.
167472 if(fading)
7884 {
7885
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1715 times.
1716 if(++clk4 > 60)
7886 {
7887 1 clk4=0;
7888 1 superman=0;
7889 1 fading=0;
7890
7891
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if(flags&guy_armos && z==0 && fakez==0)
7892 removearmos(x,y);
7893
7894 1 clk2=0;
7895
7896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!canmove(down,(zfix)8,spw_none,false))
7897 {
7898 1 dir=0;
7899 1 y = TRUNCATE_TILE(y.getInt());
7900 1 }
7901
7902 1 return Dead(index);
7903 }
7904
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1715 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1715 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
7905 removearmos(x,y);
7906 1715 }
7907
7908 167471 return enemy::animate(index);
7909 167472 }
7910
7911 351659 void eFire::draw(BITMAP *dest)
7912 {
7913 351659 update_enemy_frame();
7914 351659 enemy::draw(dest);
7915 351659 }
7916
7917 415 int32_t eFire::takehit(weapon *w, weapon* realweap)
7918 {
7919 415 int32_t wpnId = w->id;
7920 415 int32_t wpnDir = w->dir;
7921
7922
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
415 if(wpnId==wHammer && shield && (flags & guy_bkshield)
7923 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
7924 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
7925 {
7926 shield = false;
7927 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
7928
7929 if(get_qr(qr_BRKNSHLDTILES))
7930 o_tile=s_tile;
7931 }
7932
7933 415 int32_t ret = enemy::takehit(w,realweap);
7934 415 return ret;
7935 }
7936
7937 void eFire::break_shield()
7938 {
7939 if(!shield)
7940 return;
7941
7942 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
7943 shield=false;
7944
7945 if(get_qr(qr_BRKNSHLDTILES))
7946 o_tile=s_tile;
7947 }
7948
7949 void eFire::repair_shield()
7950 {
7951 if (shield)
7952 return;
7953
7954 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
7955 return;
7956
7957 shield = true;
7958
7959 if (get_qr(qr_BRKNSHLDTILES))
7960 {
7961 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
7962 else o_tile = d->tile;
7963 }
7964 }
7965
7966 7630 eOther::eOther(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7967 7630 {
7968 7630 clk4=0;
7969
4/8
✓ Branch 0 taken 7630 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7630 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7630 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7630 times.
✗ Branch 7 not taken.
7630 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
7970
7971 // Spawn type
7972
2/4
✓ Branch 0 taken 7630 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7630 times.
7630 if(flags & guy_fade_flicker)
7973 {
7974 clk=0;
7975 superman = 1;
7976 fading=fade_flicker;
7977 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7978 dir=down;
7979
7980 if(!canmove(down,(zfix)8,spw_none,false))
7981 clk3=int32_t(13.0/step);
7982 }
7983
3/4
✓ Branch 0 taken 7630 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6443 times.
✓ Branch 3 taken 1187 times.
7630 else if(flags & guy_fade_instant)
7984 {
7985 1187 clk=0;
7986 1187 }
7987
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 7623 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
7630 if (SIZEflags != 0) init_size_flags();;
7988 7630 }
7989
7990 1981512 bool eOther::animate(int32_t index)
7991 {
7992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1981512 times.
1981512 if(switch_hooked) return enemy::animate(index);
7993
3/4
✓ Branch 0 taken 1979926 times.
✓ Branch 1 taken 1586 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1979926 times.
1981512 if(fallclk||drownclk) return enemy::animate(index);
7994
2/2
✓ Branch 0 taken 1971390 times.
✓ Branch 1 taken 8536 times.
1979926 if(fading)
7995 {
7996
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 8507 times.
8536 if(++clk4 > 60)
7997 {
7998 29 clk4=0;
7999 29 superman=0;
8000 29 fading=0;
8001
8002
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
29 if(flags&guy_armos && z==0 && fakez==0)
8003 removearmos(x,y);
8004
8005 29 clk2=0;
8006
8007
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 2 times.
29 if(!canmove(down,(zfix)8,spw_none,false))
8008 {
8009 2 dir=0;
8010 2 y = TRUNCATE_TILE(y.getInt());
8011 2 }
8012
8013 29 return Dead(index);
8014 }
8015
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8507 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
8507 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8016 removearmos(x,y);
8017 8507 }
8018
8019 1979897 return enemy::animate(index);
8020 1981512 }
8021
8022 2087673 void eOther::draw(BITMAP *dest)
8023 {
8024 2087673 update_enemy_frame();
8025 2087673 enemy::draw(dest);
8026 2087673 }
8027
8028 14773 int32_t eOther::takehit(weapon *w, weapon* realweap)
8029 {
8030 14773 int32_t wpnId = w->id;
8031 14773 int32_t wpnDir = w->dir;
8032
8033
3/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 14731 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
14773 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8034 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8035 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8036 {
8037 shield = false;
8038 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8039
8040 if(get_qr(qr_BRKNSHLDTILES))
8041 o_tile=s_tile;
8042 }
8043
8044 14773 int32_t ret = enemy::takehit(w,realweap);
8045 14773 return ret;
8046 }
8047
8048 void eOther::break_shield()
8049 {
8050 if(!shield)
8051 return;
8052
8053 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8054 shield=false;
8055
8056 if(get_qr(qr_BRKNSHLDTILES))
8057 o_tile=s_tile;
8058 }
8059
8060 void eOther::repair_shield()
8061 {
8062 if (shield)
8063 return;
8064
8065 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
8066 return;
8067
8068 shield = true;
8069
8070 if (get_qr(qr_BRKNSHLDTILES))
8071 {
8072 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
8073 else o_tile = d->tile;
8074 }
8075 }
8076
8077 eScript::eScript(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8078 {
8079 clk4=0;
8080 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
8081
8082 // Spawn type
8083 if(flags & guy_fade_flicker)
8084 {
8085 clk=0;
8086 superman = 1;
8087 fading=fade_flicker;
8088 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8089 dir=down;
8090
8091 if(!canmove(down,(zfix)8,spw_none,false))
8092 clk3=int32_t(13.0/step);
8093 }
8094 else if(flags & guy_fade_instant)
8095 {
8096 clk=0;
8097 }
8098 if (SIZEflags != 0) init_size_flags();;
8099 }
8100
8101 bool eScript::animate(int32_t index)
8102 {
8103 if(switch_hooked) return enemy::animate(index);
8104 if(fallclk||drownclk) return enemy::animate(index);
8105 if(fading)
8106 {
8107 if(++clk4 > 60)
8108 {
8109 clk4=0;
8110 superman=0;
8111 fading=0;
8112
8113 if(flags&guy_armos && z==0 && fakez==0)
8114 removearmos(x,y);
8115
8116 clk2=0;
8117
8118 if(!canmove(down,(zfix)8,spw_none,false))
8119 {
8120 dir=0;
8121 y = TRUNCATE_TILE(y.getInt());
8122 }
8123
8124 return Dead(index);
8125 }
8126 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8127 removearmos(x,y);
8128 }
8129
8130 return enemy::animate(index);
8131 }
8132
8133 void eScript::draw(BITMAP *dest)
8134 {
8135 update_enemy_frame();
8136 enemy::draw(dest);
8137 }
8138
8139 int32_t eScript::takehit(weapon *w, weapon* realweap)
8140 {
8141 int32_t wpnId = w->id;
8142 int32_t wpnDir = w->dir;
8143
8144 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8145 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8146 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8147 {
8148 shield = false;
8149 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8150
8151 if(get_qr(qr_BRKNSHLDTILES))
8152 o_tile=s_tile;
8153 }
8154
8155 int32_t ret = enemy::takehit(w,realweap);
8156 return ret;
8157 }
8158
8159 void eScript::break_shield()
8160 {
8161 if(!shield)
8162 return;
8163
8164 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8165 shield=false;
8166
8167 if(get_qr(qr_BRKNSHLDTILES))
8168 o_tile=s_tile;
8169 }
8170
8171 void eScript::repair_shield()
8172 {
8173 if (shield)
8174 return;
8175
8176 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
8177 return;
8178
8179 shield = true;
8180
8181 if (get_qr(qr_BRKNSHLDTILES))
8182 {
8183 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
8184 else o_tile = d->tile;
8185 }
8186 }
8187
8188
8189 eFriendly::eFriendly(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8190 {
8191 clk4=0;
8192 hyofs = -32768; //No hitbox initially.
8193 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
8194
8195 // Spawn type
8196 if(flags & guy_fade_flicker)
8197 {
8198 clk=0;
8199 superman = 1;
8200 fading=fade_flicker;
8201 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8202 dir=down;
8203
8204 if(!canmove(down,(zfix)8,spw_none,false))
8205 clk3=int32_t(13.0/step);
8206 }
8207 else if(flags & guy_fade_instant)
8208 {
8209 clk=0;
8210 }
8211 if (SIZEflags != 0) init_size_flags();;
8212 }
8213
8214 bool eFriendly::animate(int32_t index)
8215 {
8216 if(switch_hooked) return enemy::animate(index);
8217 if(fallclk||drownclk) return enemy::animate(index);
8218 if(fading)
8219 {
8220 if(++clk4 > 60)
8221 {
8222 clk4=0;
8223 superman=0;
8224 fading=0;
8225
8226 if(flags&guy_armos && z==0 && fakez==0)
8227 removearmos(x,y);
8228
8229 clk2=0;
8230
8231 if(!canmove(down,(zfix)8,spw_none,false))
8232 {
8233 dir=0;
8234 y = TRUNCATE_TILE(y.getInt());
8235 }
8236
8237 return Dead(index);
8238 }
8239 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8240 removearmos(x,y);
8241 }
8242
8243 return enemy::animate(index);
8244 }
8245
8246 void eFriendly::draw(BITMAP *dest)
8247 {
8248 update_enemy_frame();
8249 enemy::draw(dest);
8250 }
8251
8252 int32_t eFriendly::takehit(weapon *w, weapon* realweap)
8253 {
8254 int32_t wpnId = w->id;
8255 int32_t wpnDir = w->dir;
8256
8257 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8258 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8259 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8260 {
8261 shield = false;
8262 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8263
8264 if(get_qr(qr_BRKNSHLDTILES))
8265 o_tile=s_tile;
8266 }
8267
8268 int32_t ret = enemy::takehit(w,realweap);
8269 return ret;
8270 }
8271
8272 void eFriendly::break_shield()
8273 {
8274 if(!shield)
8275 return;
8276
8277 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8278 shield=false;
8279
8280 if(get_qr(qr_BRKNSHLDTILES))
8281 o_tile=s_tile;
8282 }
8283
8284 void eFriendly::repair_shield()
8285 {
8286 if (shield)
8287 return;
8288
8289 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
8290 return;
8291
8292 shield = true;
8293
8294 if (get_qr(qr_BRKNSHLDTILES))
8295 {
8296 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
8297 else o_tile = d->tile;
8298 }
8299 }
8300
8301
8302 780032 void enemy::removearmos(int32_t ax,int32_t ay)
8303 {
8304
2/2
✓ Branch 0 taken 779016 times.
✓ Branch 1 taken 1016 times.
780032 if(did_armos)
8305 779016 return;
8306 1016 did_armos=true;
8307 1016 auto handle = activated_handle;
8308
8309
2/2
✓ Branch 0 taken 316 times.
✓ Branch 1 taken 700 times.
1016 auto layer = handle ? handle->layer() : 0;
8310
3/4
✓ Branch 0 taken 316 times.
✓ Branch 1 taken 700 times.
✓ Branch 2 taken 316 times.
✗ Branch 3 not taken.
1016 if (!handle || handle->is_rpos())
8311 1016 handle = get_rpos_handle_for_world_xy(ax, ay, layer);
8312 1016 mapscr* scr = handle->get_mapscr();
8313
8314 1374 auto [tx, ty] = handle->xy();
8315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1016 times.
1016 if (handle->is_rpos())
8316 {
8317 2032 tx = TRUNCATE_TILE(ax);
8318 2032 ty = TRUNCATE_TILE(ay);
8319 1016 }
8320
8321 1016 int32_t f = handle->sflag();
8322 1016 int32_t f2 = handle->cflag();
8323
8324
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 176 times.
1016 if (handle->ctype() != cARMOS)
8325 840 return;
8326
8327
8328
3/4
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 154 times.
176 if(f == mfARMOS_SECRET || f2 == mfARMOS_SECRET)
8329 {
8330 22 handle->set_data(scr->secretcombo[sSTAIRS]);
8331 22 handle->set_cset(scr->secretcset[sSTAIRS]);
8332 22 handle->set_sflag(scr->secretflag[sSTAIRS]);
8333 22 sfx(scr->secretsfx);
8334 22 }
8335 else
8336 {
8337 154 handle->set_data(scr->undercombo);
8338 154 handle->set_cset(scr->undercset);
8339 154 handle->set_sflag(0);
8340 }
8341
8342
3/4
✓ Branch 0 taken 173 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 173 times.
176 if(f == mfARMOS_ITEM || f2 == mfARMOS_ITEM)
8343 {
8344
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if(!getmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (scr->flags9&fBELOWRETURN))
8345 {
8346 6 additem(tx,ty,scr->catchall, (ipONETIME2 + ipBIGRANGE) | ((scr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8347 3 sfx(scr->secretsfx);
8348 3 }
8349 3 }
8350
8351 528 putcombo(scrollbuf,tx,ty,handle->data(),handle->cset());
8352 780032 }
8353
8354 461 eGhini::eGhini(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8355 461 {
8356 461 fading=fade_flicker;
8357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
461 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8358 461 dir=12;
8359 461 movestatus=1;
8360
1/2
✓ Branch 0 taken 461 times.
✗ Branch 1 not taken.
461 step=0;
8361 461 clk=0;
8362 461 clk4=0;
8363
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
461 if (SIZEflags != 0) init_size_flags();;
8364 461 }
8365
8366 117025 bool eGhini::animate(int32_t index)
8367 {
8368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117025 times.
117025 if(switch_hooked) return enemy::animate(index);
8369
2/4
✓ Branch 0 taken 117025 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 117025 times.
117025 if(fallclk||drownclk) return enemy::animate(index);
8370
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 116975 times.
117025 if(dying)
8371 50 return Dead(index);
8372
8373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116975 times.
116975 if(dmisc1)
8374 {
8375
2/2
✓ Branch 0 taken 89752 times.
✓ Branch 1 taken 27223 times.
116975 if(misc)
8376 {
8377
2/2
✓ Branch 0 taken 34899 times.
✓ Branch 1 taken 54853 times.
89752 if(clk4>160)
8378 54853 misc=2;
8379
8380
2/2
✓ Branch 0 taken 34899 times.
✓ Branch 1 taken 54853 times.
89752 floater_walk((misc==1)?0:rate,hrate,zslongToFix(dstep*100),zslongToFix(dstep*10),10,dmisc16,dmisc17); //120,10);
8381 89752 removearmos(x,y);
8382 89752 }
8383
2/2
✓ Branch 0 taken 26798 times.
✓ Branch 1 taken 425 times.
27223 else if(clk4>=60)
8384 {
8385 425 misc=1;
8386 425 clk3=32;
8387 425 fading=0;
8388
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 285 times.
425 if (activated_handle)
8389 {
8390 140 activation_counters[activated_handle->layer()][activated_handle->id()] = 0;
8391 140 removearmos(x, y);
8392 140 }
8393 else
8394 {
8395 285 rpos_t rpos = COMBOPOS_REGION_B(x, y);
8396
1/2
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
285 if (rpos != rpos_t::None)
8397 {
8398 285 activation_counters[0][int(rpos)] = 0;
8399 285 removearmos(x,y);
8400 285 }
8401 }
8402 425 }
8403 116975 }
8404
8405 116975 clk4++;
8406
8407 116975 return enemy::animate(index);
8408 117025 }
8409
8410 238808 void eGhini::draw(BITMAP *dest)
8411 {
8412 238808 update_enemy_frame();
8413 238808 enemy::draw(dest);
8414 238808 }
8415
8416 2 void eGhini::kickbucket()
8417 {
8418 2 hp=-1000; // don't call death_sfx()
8419 2 }
8420
8421
2/4
✓ Branch 0 taken 5212 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5212 times.
✗ Branch 3 not taken.
10424 eTektite::eTektite(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8422 5212 {
8423
1/2
✓ Branch 0 taken 5212 times.
✗ Branch 1 not taken.
5212 old_y=y;
8424 5212 dir=down;
8425 5212 misc=1;
8426 5212 clk=-15;
8427
8428
2/2
✓ Branch 0 taken 2649 times.
✓ Branch 1 taken 2563 times.
5212 if(!BSZ)
8429
1/2
✓ Branch 0 taken 2649 times.
✗ Branch 1 not taken.
2649 clk*=zc_oldrand()%3+1;
8430
8431 // avoid divide by 0 errors
8432
1/2
✓ Branch 0 taken 5212 times.
✗ Branch 1 not taken.
5212 if(dmisc1 == 0)
8433 dmisc1 = 24;
8434
8435
1/2
✓ Branch 0 taken 5212 times.
✗ Branch 1 not taken.
5212 if(dmisc2 == 0)
8436 dmisc2 = 3;
8437
8438 //nets+760;
8439
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5212 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5212 if (SIZEflags != 0) init_size_flags();;
8440 5212 }
8441
8442 1436590 bool eTektite::animate(int32_t index)
8443 {
8444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1436590 times.
1436590 if(switch_hooked) return enemy::animate(index);
8445
4/4
✓ Branch 0 taken 1427644 times.
✓ Branch 1 taken 8946 times.
✓ Branch 2 taken 8946 times.
✓ Branch 3 taken 1425242 times.
1436590 if(fallclk||drownclk) return enemy::animate(index);
8446
2/2
✓ Branch 0 taken 26667 times.
✓ Branch 1 taken 1398575 times.
1425242 if(dying)
8447 26667 return Dead(index);
8448
8449
2/2
✓ Branch 0 taken 1361472 times.
✓ Branch 1 taken 37103 times.
1398575 if(clk==0)
8450 {
8451 37103 removearmos(x,y);
8452 37103 }
8453
8454
2/2
✓ Branch 0 taken 1057392 times.
✓ Branch 1 taken 341183 times.
1398575 if(get_qr(qr_ENEMIESZAXIS))
8455 {
8456 341183 y=floor_y;
8457 341183 }
8458
8459
9/10
✓ Branch 0 taken 1283739 times.
✓ Branch 1 taken 114836 times.
✓ Branch 2 taken 1270175 times.
✓ Branch 3 taken 13564 times.
✓ Branch 4 taken 1270175 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11176 times.
✓ Branch 7 taken 1258999 times.
✓ Branch 8 taken 11960 times.
✓ Branch 9 taken 21878 times.
1398575 if(clk>=0 && !stunclk && !frozenclock && (!watch || misc==0))
8460 {
8461
4/4
✓ Branch 0 taken 20260 times.
✓ Branch 1 taken 421702 times.
✓ Branch 2 taken 345150 times.
✓ Branch 3 taken 493765 times.
1280877 switch(misc)
8462 {
8463 case 0: // normal
8464
2/2
✓ Branch 0 taken 410469 times.
✓ Branch 1 taken 11233 times.
421702 if (!zc::math::SafeMod(zc_oldrand(), dmisc1))
8465 {
8466 11233 misc=1;
8467 11233 clk2=32;
8468 11233 }
8469
8470 421702 break;
8471
8472 case 1: // waiting to pounce
8473
2/2
✓ Branch 0 taken 324515 times.
✓ Branch 1 taken 20635 times.
345150 if(--clk2<=0)
8474 {
8475 20635 int32_t r=zc_oldrand();
8476 20635 misc=2;
8477 20635 step=0-(zslongToFix(dstep*100)); // initial speed
8478 20635 clk3=(r&1)+2; // left or right
8479 20635 clk2start=clk2=(r&31)+10; // flight time
8480
8481
2/2
✓ Branch 0 taken 18212 times.
✓ Branch 1 taken 2423 times.
20635 if(y<32) clk2+=2; // make them come down from top of screen
8482
8483
2/2
✓ Branch 0 taken 15717 times.
✓ Branch 1 taken 4918 times.
20635 if(y>world_h-64) clk2-=2; // make them go back up
8484
8485 20635 cstart=c = 9-((r&31)>>3); // time before gravity kicks in
8486 20635 }
8487
8488 345150 break;
8489
8490 case 2: // in flight
8491 493765 move(step);
8492
8493
2/2
✓ Branch 0 taken 234357 times.
✓ Branch 1 taken 259408 times.
493765 if(step>0) //going down
8494 {
8495
2/2
✓ Branch 0 taken 632 times.
✓ Branch 1 taken 233725 times.
234357 if(COMBOTYPE(x+8,y+16)==cNOJUMPZONE)
8496 {
8497 632 step=0-step;
8498 632 }
8499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 233725 times.
233725 else if(COMBOTYPE(x+8,y+16)==cNOENEMY)
8500 {
8501 step=0-step;
8502 }
8503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 233725 times.
233725 else if(ispitfall(x+8,y+16))
8504 {
8505 step=0-step;
8506 }
8507
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 233678 times.
233725 else if(MAPFLAG(x+8,y+16)==mfNOENEMY)
8508 {
8509 47 step=0-step;
8510 47 }
8511
2/2
✓ Branch 0 taken 233667 times.
✓ Branch 1 taken 11 times.
233678 else if(MAPCOMBOFLAG(x+8,y+16)==mfNOENEMY)
8512 {
8513 11 step=0-step;
8514 11 }
8515 234357 }
8516
2/2
✓ Branch 0 taken 15166 times.
✓ Branch 1 taken 244242 times.
259408 else if(step<0)
8517 {
8518
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 243804 times.
244242 if(COMBOTYPE(x+8,y)==cNOJUMPZONE)
8519 {
8520 438 step=0-step;
8521 438 }
8522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243804 times.
243804 else if(COMBOTYPE(x+8,y)==cNOENEMY)
8523 {
8524 step=0-step;
8525 }
8526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243804 times.
243804 else if(ispitfall(x+8,y))
8527 {
8528 step=0-step;
8529 }
8530
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 243783 times.
243804 else if(MAPFLAG(x+8,y)==mfNOENEMY)
8531 {
8532 21 step=0-step;
8533 21 }
8534
2/2
✓ Branch 0 taken 243764 times.
✓ Branch 1 taken 19 times.
243783 else if(MAPCOMBOFLAG(x+8,y)==mfNOENEMY)
8535 {
8536 19 step=0-step;
8537 19 }
8538 244242 }
8539
8540
2/2
✓ Branch 0 taken 244331 times.
✓ Branch 1 taken 249434 times.
493765 if(clk3==left)
8541 {
8542
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 244056 times.
244331 if(COMBOTYPE(x,y+8)==cNOJUMPZONE)
8543 {
8544 275 clk3^=1;
8545 275 }
8546
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 244050 times.
244056 else if(COMBOTYPE(x,y+8)==cNOENEMY)
8547 {
8548 6 clk3^=1;
8549 6 }
8550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244050 times.
244050 else if(ispitfall(x,y+8))
8551 {
8552 clk3^=1;
8553 }
8554
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 244020 times.
244050 else if(MAPFLAG(x,y+8)==mfNOENEMY)
8555 {
8556 30 clk3^=1;
8557 30 }
8558
2/2
✓ Branch 0 taken 244008 times.
✓ Branch 1 taken 12 times.
244020 else if(MAPCOMBOFLAG(x,y+8)==mfNOENEMY)
8559 {
8560 12 clk3^=1;
8561 12 }
8562 244331 }
8563 else
8564 {
8565
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 249158 times.
249434 if(COMBOTYPE(x+16,y+8)==cNOJUMPZONE)
8566 {
8567 276 clk3^=1;
8568 276 }
8569
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 249146 times.
249158 else if(COMBOTYPE(x+16,y+8)==cNOENEMY)
8570 {
8571 12 clk3^=1;
8572 12 }
8573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 249146 times.
249146 else if(ispitfall(x+16,y+8))
8574 {
8575 clk3^=1;
8576 }
8577
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 249141 times.
249146 else if(MAPFLAG(x+16,y+8)==mfNOENEMY)
8578 {
8579 5 clk3^=1;
8580 5 }
8581
2/2
✓ Branch 0 taken 249129 times.
✓ Branch 1 taken 12 times.
249141 else if(MAPCOMBOFLAG(x+16,y+8)==mfNOENEMY)
8582 {
8583 12 clk3^=1;
8584 12 }
8585 }
8586
8587 493765 --c;
8588
8589
4/4
✓ Branch 0 taken 151531 times.
✓ Branch 1 taken 342234 times.
✓ Branch 2 taken 320688 times.
✓ Branch 3 taken 173077 times.
493765 if(c<0 && step<zslongToFix(dstep*100))
8590 {
8591 173077 step+=zslongToFix(dmisc3*100);
8592 173077 }
8593
8594 493765 int32_t nb=get_qr(qr_NOBORDER) ? 16 : 0;
8595
8596
2/2
✓ Branch 0 taken 493043 times.
✓ Branch 1 taken 722 times.
493765 if(x<=16-nb) clk3=right;
8597
8598
2/2
✓ Branch 0 taken 492773 times.
✓ Branch 1 taken 992 times.
493765 if(x>=world_w-32+nb) clk3=left;
8599
8600 493765 x += (clk3==left) ? -1 : 1;
8601
8602
4/4
✓ Branch 0 taken 29039 times.
✓ Branch 1 taken 464726 times.
✓ Branch 2 taken 10130 times.
✓ Branch 3 taken 454596 times.
493765 if((--clk2<=0 && y>=16-nb) || y>=world_h-32+nb)
8603 {
8604
4/4
✓ Branch 0 taken 1621 times.
✓ Branch 1 taken 17288 times.
✓ Branch 2 taken 1436 times.
✓ Branch 3 taken 185 times.
39169 if(y>=world_h-32+nb && get_qr(qr_ENEMIESZAXIS))
8605 {
8606 185 step=0-step;
8607 185 y--;
8608 185 }
8609
2/2
✓ Branch 0 taken 5796 times.
✓ Branch 1 taken 12928 times.
18724 else if (zc::math::SafeMod(zc_oldrand(), dmisc2)) //land and wait
8610 {
8611 12928 clk=misc=0;
8612 12928 } //land and jump again
8613 else
8614 {
8615 5796 misc=1;
8616 5796 clk2=0;
8617 }
8618 18909 }
8619
8620 473505 break;
8621 } // switch
8622 1260617 }
8623
8624
4/4
✓ Branch 0 taken 341183 times.
✓ Branch 1 taken 1059794 times.
✓ Branch 2 taken 231206 times.
✓ Branch 3 taken 109977 times.
1400977 if(get_qr(qr_ENEMIESZAXIS) && misc==2)
8625 {
8626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109977 times.
109977 if (moveflags & move_use_fake_z)
8627 {
8628 int32_t tempy = floor_y;
8629 fakez=zc_max(0,zc_min(clk2start-clk2,clk2));
8630 floor_y = y;
8631 y=tempy-fakez;
8632 old_y = y;
8633 }
8634 else
8635 {
8636 109977 int32_t tempy = floor_y;
8637
6/6
✓ Branch 0 taken 55216 times.
✓ Branch 1 taken 54761 times.
✓ Branch 2 taken 104073 times.
✓ Branch 3 taken 5904 times.
✓ Branch 4 taken 50747 times.
✓ Branch 5 taken 53326 times.
109977 z=zc_max(0,zc_min(clk2start-clk2,clk2));
8638 109977 floor_y = y;
8639 109977 y=tempy-z;
8640 109977 old_y = y;
8641 }
8642 109977 }
8643
8644
4/4
✓ Branch 0 taken 13564 times.
✓ Branch 1 taken 1387413 times.
✓ Branch 2 taken 2927 times.
✓ Branch 3 taken 10637 times.
1400977 if(stunclk && (clk&31)==1)
8645 10637 clk=0;
8646
8647 1400977 return enemy::animate(index);
8648 1427644 }
8649
8650 809450 void eTektite::drawshadow(BITMAP *dest,bool translucent)
8651 {
8652
5/6
✓ Branch 0 taken 632172 times.
✓ Branch 1 taken 177278 times.
✓ Branch 2 taken 632172 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 606981 times.
✓ Branch 5 taken 25191 times.
809450 if(z<1 && fakez<1 && get_qr(qr_ENEMIESZAXIS))
8653 25191 return;
8654
8655 784259 int32_t tempy=yofs;
8656 784259 int32_t fdiv = frate/4;
8657
1/2
✓ Branch 0 taken 784259 times.
✗ Branch 1 not taken.
784259 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
8658
1/2
✓ Branch 0 taken 784259 times.
✗ Branch 1 not taken.
784259 int32_t f2=get_qr(qr_NEWENEMYTILES)?
8659 784259 efrate:((clk>=(frate>>1))?1:0);
8660 784259 flip = 0;
8661 784259 shadowtile = wpnsbuf[spr_shadow].tile;
8662
8663
1/2
✓ Branch 0 taken 784259 times.
✗ Branch 1 not taken.
784259 if(get_qr(qr_NEWENEMYTILES))
8664 {
8665
2/2
✓ Branch 0 taken 581728 times.
✓ Branch 1 taken 202531 times.
784259 if(misc==0)
8666 {
8667 202531 shadowtile+=f2;
8668 202531 }
8669
2/2
✓ Branch 0 taken 259363 times.
✓ Branch 1 taken 322365 times.
581728 else if(misc!=1)
8670 322365 shadowtile+=2;
8671 784259 }
8672 else
8673 {
8674 if(misc==0)
8675 {
8676 shadowtile += f2 ? 1 : 0;
8677 }
8678 else if(misc!=1)
8679 {
8680 ++shadowtile;
8681 }
8682 }
8683
8684 784259 yofs+=8;
8685
8686
4/4
✓ Branch 0 taken 606981 times.
✓ Branch 1 taken 177278 times.
✓ Branch 2 taken 344816 times.
✓ Branch 3 taken 262165 times.
784259 if(!get_qr(qr_ENEMIESZAXIS) && misc==2)
8687 {
8688
6/6
✓ Branch 0 taken 134327 times.
✓ Branch 1 taken 127838 times.
✓ Branch 2 taken 244709 times.
✓ Branch 3 taken 17456 times.
✓ Branch 4 taken 123717 times.
✓ Branch 5 taken 120992 times.
262165 yofs+=zc_max(0,zc_min(clk2start-clk2,clk2));
8689 262165 }
8690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 784259 times.
784259 if(!shadow_overpit(this))
8691 784259 enemy::drawshadow(dest,translucent);
8692 784259 yofs=tempy;
8693 809450 }
8694
8695 2052032 void eTektite::draw(BITMAP *dest)
8696 {
8697 2052032 update_enemy_frame();
8698 2052032 enemy::draw(dest);
8699 2052032 }
8700
8701 732 eItemFairy::eItemFairy(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8702 732 {
8703
2/4
✓ Branch 0 taken 732 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 732 times.
✗ Branch 3 not taken.
732 step=zslongToFix(guysbuf[id&0xFFF].step*100);
8704 732 superman=1;
8705 732 dir=8;
8706 732 hxofs=1000;
8707 732 mainguy=false;
8708 732 count_enemy=false;
8709
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
732 if (SIZEflags != 0) init_size_flags();;
8710 732 }
8711
8712 280245 bool eItemFairy::animate(int32_t index)
8713 {
8714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280245 times.
280245 if(switch_hooked) return enemy::animate(index);
8715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280245 times.
280245 if(dying)
8716 return Dead(index);
8717
8718 //if(clk>32)
8719 280245 misc=1;
8720 280245 bool w=watch;
8721 280245 watch=false;
8722 280245 variable_walk_8(misc?3:0,0,8,spw_floater);
8723 280245 watch=w;
8724
8725
2/2
✓ Branch 0 taken 1516 times.
✓ Branch 1 taken 278729 times.
280245 if(clk==0)
8726 {
8727 1516 removearmos(x,y);
8728 1516 }
8729
8730 280245 return enemy::animate(index);
8731 280245 }
8732
8733 562846 void eItemFairy::draw(BITMAP *dest)
8734 {
8735 //these are here to bypass compiler warnings about unused arguments
8736 562846 dest=dest;
8737 562846 }
8738
8739 1825 ePeahat::ePeahat(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8740 1825 {
8741 //floater_walk(int32_t rate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
8742
10/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1825 times.
✓ Branch 2 taken 1825 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1825 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1825 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1825 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1825 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1825 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1825 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1825 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 1825 times.
✗ Branch 19 not taken.
1825 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, dmisc16,dmisc17); // 80, 16);
8743 1825 dir=8;
8744 1825 movestatus=1;
8745 1825 clk=0;
8746
1/2
✓ Branch 0 taken 1825 times.
✗ Branch 1 not taken.
1825 step=0;
8747 //nets+720;
8748
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1825 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1825 if (SIZEflags != 0) init_size_flags();;
8749 1825 }
8750
8751 520615 bool ePeahat::animate(int32_t index)
8752 {
8753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 520615 times.
520615 if(switch_hooked) return enemy::animate(index);
8754
2/4
✓ Branch 0 taken 520615 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 520615 times.
520615 if(fallclk||drownclk) return enemy::animate(index);
8755
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 520537 times.
520615 if(slide())
8756 {
8757 78 update_current_screen();
8758 78 return false;
8759 }
8760
8761
2/2
✓ Branch 0 taken 1030 times.
✓ Branch 1 taken 519507 times.
520537 if(dying)
8762 1030 return Dead(index);
8763
8764
2/2
✓ Branch 0 taken 3083 times.
✓ Branch 1 taken 516424 times.
519507 if(clk==0)
8765 {
8766 3083 removearmos(x,y);
8767 3083 }
8768
8769
4/4
✓ Branch 0 taken 516389 times.
✓ Branch 1 taken 3118 times.
✓ Branch 2 taken 253336 times.
✓ Branch 3 taken 263053 times.
519507 if(stunclk==0 && clk>96)
8770 263053 misc=1;
8771
8772
2/2
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 517105 times.
519507 if(!watch)
8773
2/2
✓ Branch 0 taken 171491 times.
✓ Branch 1 taken 345614 times.
517105 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, 80, 16);
8774
8775
3/4
✓ Branch 0 taken 100018 times.
✓ Branch 1 taken 419489 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100018 times.
519507 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
8776 {
8777
1/2
✓ Branch 0 taken 100018 times.
✗ Branch 1 not taken.
100018 if (moveflags & move_use_fake_z) fakez=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8778 100018 else z=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8779 100018 }
8780
8781
4/4
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 517105 times.
✓ Branch 2 taken 768 times.
✓ Branch 3 taken 1634 times.
519507 if(watch && get_qr(qr_PEAHATCLOCKVULN))
8782 1634 superman=0;
8783 else
8784
2/2
✓ Branch 0 taken 9811 times.
✓ Branch 1 taken 508062 times.
517873 superman=(movestatus && !get_qr(qr_ENEMIESZAXIS)) ? 1 : 0;
8785 //stunclk=0; //Not sure what was going on here, or what was intended. Why was this set to 0? -Z
8786
2/2
✓ Branch 0 taken 264937 times.
✓ Branch 1 taken 254570 times.
519507 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x250 )
8787 {
8788
2/2
✓ Branch 0 taken 261822 times.
✓ Branch 1 taken 3115 times.
264937 if ( stunclk ) --stunclk;
8789 264937 }
8790 254570 else stunclk = 0; //Was probably this way in 2.10 quests. if not, then we never need to clear it. -Z
8791 //Pretty sure this was always an error. -Z ( 14FEB2019 )
8792
8793
8794
2/2
✓ Branch 0 taken 519267 times.
✓ Branch 1 taken 240 times.
519507 if(x<16) dir=right; //this is ugly, but so is moving or creating these guys with scripts.
8795
8796 519507 return enemy::animate(index);
8797 520615 }
8798
8799 334520 void ePeahat::drawshadow(BITMAP *dest, bool translucent)
8800 {
8801 334520 int32_t tempy=yofs;
8802 334520 flip = 0;
8803 334520 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
8804
8805
2/2
✓ Branch 0 taken 88089 times.
✓ Branch 1 taken 246431 times.
334520 if(!get_qr(qr_ENEMIESZAXIS))
8806 {
8807 246431 yofs+=8;
8808 246431 yofs+=int32_t(step/zslongToFix(dstep*10));
8809 246431 }
8810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334520 times.
334520 if(!shadow_overpit(this))
8811 334520 enemy::drawshadow(dest,translucent);
8812 334520 yofs=tempy;
8813 334520 }
8814
8815 1144330 void ePeahat::draw(BITMAP *dest)
8816 {
8817 1144330 update_enemy_frame();
8818 1144330 enemy::draw(dest);
8819 1144330 }
8820
8821 4136 int32_t ePeahat::takehit(weapon *w, weapon* realweap)
8822 {
8823 4136 int32_t wpnId = w->id;
8824 4136 int32_t enemyHitWeapon = w->parentitem;
8825
8826
3/6
✓ Branch 0 taken 4136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4136 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4136 times.
4136 if(dying || clk<0 || hclk>0)
8827 return 0;
8828
8829
4/4
✓ Branch 0 taken 3381 times.
✓ Branch 1 taken 755 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 206 times.
4380 if(superman && !(wpnId==wSBomb) // vulnerable to super bombs
8830 // fire boomerang, for nailing peahats
8831
4/6
✓ Branch 0 taken 3381 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3137 times.
✓ Branch 3 taken 244 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 244 times.
3381 && !(wpnId==wBrang && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))>0))
8832 3343 return 0;
8833
8834 // Time for a kludge...
8835 793 int32_t s = superman;
8836 793 superman = 0;
8837 793 int32_t ret = enemy::takehit(w,realweap);
8838 793 superman = s;
8839
8840 // Anyway...
8841
2/2
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 192 times.
793 if(stunclk == 160)
8842 {
8843 192 clk2=0;
8844 192 movestatus=0;
8845 192 misc=0;
8846 192 clk=0;
8847 192 step=0;
8848 192 }
8849
8850 793 return ret;
8851 4136 }
8852
8853 // auomatically kill off enemy (for rooms with ringleaders)
8854 void ePeahat::kickbucket()
8855 {
8856 hp=-1000; // don't call death_sfx()
8857 }
8858
8859 3942 eLeever::eLeever(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8860 3942 {
8861 // if(d->misc1==0) { misc=-1; clk-=16; } //Line of Sight leevers
8862
2/2
✓ Branch 0 taken 1795 times.
✓ Branch 1 taken 2147 times.
3942 if(dmisc1==0)
8863 {
8864 2147 misc=-1; //Line of Sight leevers
8865 2147 clk-=16;
8866 2147 }
8867 3942 clk3 = 0;
8868 //nets+1460;
8869 3942 temprule=(get_qr(qr_NEWENEMYTILES)) != 0;
8870 3942 submerged = false;
8871
1/4
✓ Branch 0 taken 3942 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3942 if (SIZEflags != 0) init_size_flags();;
8872 3942 }
8873
8874 923 bool eLeever::isSubmerged() const
8875 {
8876 923 return misc <= 0;
8877 }
8878
8879 1018478 bool eLeever::animate(int32_t index)
8880 {
8881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1018478 times.
1018478 if(switch_hooked) return enemy::animate(index);
8882
3/4
✓ Branch 0 taken 1018123 times.
✓ Branch 1 taken 355 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1018123 times.
1018478 if(fallclk||drownclk)
8883 {
8884 355 return enemy::animate(index);
8885 }
8886
2/2
✓ Branch 0 taken 31552 times.
✓ Branch 1 taken 986571 times.
1018123 if(dying)
8887 31552 return Dead(index);
8888
8889
2/2
✓ Branch 0 taken 941601 times.
✓ Branch 1 taken 44970 times.
986571 if(clk==0)
8890 {
8891 44970 removearmos(x,y);
8892 44970 }
8893
8894
4/4
✓ Branch 0 taken 816947 times.
✓ Branch 1 taken 169624 times.
✓ Branch 2 taken 5265 times.
✓ Branch 3 taken 811682 times.
986571 if(clk>=0 && !slide())
8895 {
8896
2/2
✓ Branch 0 taken 337868 times.
✓ Branch 1 taken 473814 times.
811682 switch(dmisc1)
8897 {
8898 case 0: //line of sight
8899 case 2:
8900
7/8
✗ Branch 0 not taken.
✓ Branch 1 taken 124459 times.
✓ Branch 2 taken 49109 times.
✓ Branch 3 taken 35464 times.
✓ Branch 4 taken 15780 times.
✓ Branch 5 taken 101784 times.
✓ Branch 6 taken 4365 times.
✓ Branch 7 taken 6907 times.
337868 switch(misc) //is this leever active
8901 {
8902 case -1: //submerged
8903 {
8904
4/6
✓ Branch 0 taken 6382 times.
✓ Branch 1 taken 118077 times.
✓ Branch 2 taken 6382 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6382 times.
124459 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 0;
8905
4/4
✓ Branch 0 taken 10299 times.
✓ Branch 1 taken 114160 times.
✓ Branch 2 taken 10261 times.
✓ Branch 3 taken 38 times.
124459 if((dmisc1==2)&&(zc_oldrand()&255))
8906 {
8907 10261 break;
8908 }
8909
8910 114198 int32_t active=0;
8911
8912
2/2
✓ Branch 0 taken 783342 times.
✓ Branch 1 taken 114198 times.
897540 for(int32_t i=0; i<guys.Count(); i++)
8913 {
8914
4/4
✓ Branch 0 taken 627294 times.
✓ Branch 1 taken 156048 times.
✓ Branch 2 taken 401598 times.
✓ Branch 3 taken 225696 times.
783342 if(guys.spr(i)->id==id && (((enemy*)guys.spr(i))->misc>=0))
8915 {
8916 225696 ++active;
8917 225696 }
8918 783342 }
8919
8920
2/2
✓ Branch 0 taken 112327 times.
✓ Branch 1 taken 1871 times.
114198 if(active<((dmisc1==2)?1:2))
8921 {
8922 1871 misc=0; //activate this one
8923 1871 clk3=1; //This needs to be set so that it knows that it's being emerged of its own will and not because it got stunned.
8924 1871 }
8925 }
8926 114198 break;
8927
8928 case 0:
8929 {
8930
8931
4/6
✓ Branch 0 taken 11920 times.
✓ Branch 1 taken 37189 times.
✓ Branch 2 taken 11920 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 11920 times.
49109 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
8932 {
8933 misc=1;
8934 clk2=0;
8935 }
8936
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 49052 times.
49109 else if (clk3<=0)
8937 {
8938 57 misc = -1;
8939 57 break;
8940 }
8941 49052 int32_t s=0;
8942
8943
2/2
✓ Branch 0 taken 273250 times.
✓ Branch 1 taken 49052 times.
322302 for(int32_t i=0; i<guys.Count(); i++)
8944 {
8945
4/4
✓ Branch 0 taken 164314 times.
✓ Branch 1 taken 108936 times.
✓ Branch 2 taken 156432 times.
✓ Branch 3 taken 7882 times.
273250 if(guys.spr(i)->id==id && ((enemy*)guys.spr(i))->misc==1)
8946 {
8947 7882 ++s;
8948 7882 }
8949 273250 }
8950
8951
2/2
✓ Branch 0 taken 7882 times.
✓ Branch 1 taken 41170 times.
49052 if(s>0)
8952 {
8953 7882 break;
8954 }
8955
8956 41170 int32_t d2=zc_oldrand()&1;
8957
8958
2/2
✓ Branch 0 taken 14509 times.
✓ Branch 1 taken 26661 times.
41170 if(HeroDir()>=left)
8959 {
8960 26661 d2+=2;
8961 26661 }
8962
8963
4/4
✓ Branch 0 taken 39722 times.
✓ Branch 1 taken 1448 times.
✓ Branch 2 taken 663 times.
✓ Branch 3 taken 39059 times.
41170 if(canplace(d2) || canplace(d2^1))
8964 {
8965 2111 misc=1;
8966 2111 clk2=0;
8967 2111 clk=0;
8968 2111 }
8969 }
8970 41170 break;
8971
8972 case 1:
8973
8974
7/8
✓ Branch 0 taken 33397 times.
✓ Branch 1 taken 2067 times.
✓ Branch 2 taken 3596 times.
✓ Branch 3 taken 29801 times.
✓ Branch 4 taken 3596 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 3595 times.
35464 if(++clk2>16||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>8)) misc=2;
8975
8976 35464 break;
8977
8978 case 2:
8979
8980
7/8
✓ Branch 0 taken 13865 times.
✓ Branch 1 taken 1915 times.
✓ Branch 2 taken 1503 times.
✓ Branch 3 taken 12362 times.
✓ Branch 4 taken 1503 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1502 times.
15780 if(++clk2>24||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>12)) misc=3;
8981
8982 15780 break;
8983
8984 // case 3: if(stunclk) break; if(scored) dir^=1; if(!canmove(dir,false)) misc=4; else move((zfix)(d->step/100.0)); break;
8985 case 3:
8986
8987
5/6
✓ Branch 0 taken 98195 times.
✓ Branch 1 taken 3589 times.
✓ Branch 2 taken 98195 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2727 times.
✓ Branch 5 taken 95468 times.
101784 if(stunclk || frozenclock || watch) break;
8988
8989
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 95326 times.
95468 if(scored) dir^=1;
8990
8991
2/2
✓ Branch 0 taken 505 times.
✓ Branch 1 taken 94963 times.
95468 if(!canmove(dir,false)) misc=4;
8992 94963 else move(zslongToFix(dstep*100));
8993
8994 95468 break;
8995
8996 case 4:
8997
4/6
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 3755 times.
✓ Branch 2 taken 610 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 610 times.
4365 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 2;
8998
2/2
✓ Branch 0 taken 3897 times.
✓ Branch 1 taken 468 times.
4365 if(--clk2<=16)
8999 {
9000 468 misc=5;
9001 468 clk=8;
9002 468 }
9003
9004 4365 break;
9005
9006 case 5:
9007
5/6
✓ Branch 0 taken 1010 times.
✓ Branch 1 taken 5897 times.
✓ Branch 2 taken 1010 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1009 times.
6907 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 1;
9008
2/2
✓ Branch 0 taken 6497 times.
✓ Branch 1 taken 410 times.
6907 if(--clk2<=0) misc=((dmisc1==2)?-1:0);
9009
9010 6907 break;
9011 } // switch(misc)
9012
9013 337868 break;
9014
9015 default: //random
9016 // step=d->misc3/100.0;
9017
9018 473814 step=zslongToFix(dmisc3*100);
9019
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 473814 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
473814 if (get_qr(qr_LEEVERS_DONT_OBEY_STUN) || (!watch && !stunclk)) ++clk2;
9020 else if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
9021 {
9022 if (clk2 < 48) clk2+=2;
9023 if (clk2 >= 300) clk2-=2;
9024 }
9025
9026
2/2
✓ Branch 0 taken 60840 times.
✓ Branch 1 taken 412974 times.
473814 if(clk2<32) misc=1;
9027
2/2
✓ Branch 0 taken 30244 times.
✓ Branch 1 taken 382730 times.
412974 else if(clk2<48) misc=2;
9028
2/2
✓ Branch 0 taken 289541 times.
✓ Branch 1 taken 93189 times.
382730 else if(clk2<300)
9029 {
9030 /*if(misc==2 && (int32_t)(dmisc3*0.48)%8)
9031 {
9032 fix_coords();
9033 }*/
9034 289541 misc=3;
9035 289541 step = zslongToFix(dstep*100);
9036 289541 }
9037
2/2
✓ Branch 0 taken 9009 times.
✓ Branch 1 taken 84180 times.
93189 else if(clk2<316) misc=2;
9038
2/2
✓ Branch 0 taken 43755 times.
✓ Branch 1 taken 40425 times.
84180 else if(clk2<412) misc=1;
9039
2/2
✓ Branch 0 taken 40151 times.
✓ Branch 1 taken 274 times.
40425 else if(clk2<540)
9040 {
9041 40151 misc=0;
9042 40151 step=0;
9043 40151 }
9044 274 else clk2=0;
9045
9046
2/2
✓ Branch 0 taken 471961 times.
✓ Branch 1 taken 1853 times.
473814 if(clk2==48) clk=0;
9047
9048 // variable_walk(d->rate, d->homing, 0);
9049 473814 variable_walk(rate, homing, 0);
9050 473814 } // switch(dmisc1)
9051 811682 }
9052
9053 986571 hxofs=(misc>=2)?0:1000;
9054 986571 return enemy::animate(index);
9055 1018478 }
9056
9057 80892 bool eLeever::canplace(int32_t d2)
9058 {
9059 80892 int32_t nx=HeroX();
9060 80892 int32_t ny=HeroY();
9061
9062
2/2
✓ Branch 0 taken 28492 times.
✓ Branch 1 taken 52400 times.
80892 if(d2<left) ny=TRUNCATE_TILE(ny);
9063 52400 else nx=TRUNCATE_TILE(nx);
9064
9065
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 14174 times.
✓ Branch 2 taken 14318 times.
✓ Branch 3 taken 26181 times.
✓ Branch 4 taken 26219 times.
80892 switch(d2)
9066 {
9067 case up:
9068
2/2
✓ Branch 0 taken 14144 times.
✓ Branch 1 taken 30 times.
14174 ny-=((dmisc1==0||dmisc1==2)?32:48);
9069 14174 break;
9070
9071 case down:
9072
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 14284 times.
14318 ny+=((dmisc1==0||dmisc1==2)?32:48);
9073
9074
4/4
✓ Branch 0 taken 10087 times.
✓ Branch 1 taken 4231 times.
✓ Branch 2 taken 10076 times.
✓ Branch 3 taken 11 times.
14318 if(ny-HeroY()<32) ny+=((dmisc1==0||dmisc1==2)?16:0);
9075
9076 14318 break;
9077
9078 case left:
9079
2/2
✓ Branch 0 taken 25528 times.
✓ Branch 1 taken 653 times.
26181 nx-=((dmisc1==0||dmisc1==2)?32:48);
9080 26181 break;
9081
9082 case right:
9083
2/2
✓ Branch 0 taken 646 times.
✓ Branch 1 taken 25573 times.
26219 nx+=((dmisc1==0||dmisc1==2)?32:48);
9084
9085
4/4
✓ Branch 0 taken 19151 times.
✓ Branch 1 taken 7068 times.
✓ Branch 2 taken 18549 times.
✓ Branch 3 taken 602 times.
26219 if(nx-HeroX()<32) nx+=((dmisc1==0||dmisc1==2)?16:0);
9086
9087 26219 break;
9088 }
9089
9090
4/4
✓ Branch 0 taken 20429 times.
✓ Branch 1 taken 60463 times.
✓ Branch 2 taken 9001 times.
✓ Branch 3 taken 11428 times.
80892 if(m_walkflag(nx,ny,spw_halfstep, dir)||m_walkflag(nx,ny-8,spw_halfstep, dir)) /*none*/
9091 69464 return false;
9092
9093
2/2
✓ Branch 0 taken 865 times.
✓ Branch 1 taken 10563 times.
11428 if(d2>=left)
9094
4/4
✓ Branch 0 taken 5025 times.
✓ Branch 1 taken 5538 times.
✓ Branch 2 taken 9317 times.
✓ Branch 3 taken 1246 times.
10563 if(m_walkflag(HeroX(),HeroY(),spw_halfstep, dir)||m_walkflag(HeroX(),HeroY()-8,spw_halfstep, dir)) /*none*/
9095 9317 return false;
9096
9097 2111 x=nx;
9098 2111 y=ny;
9099 2111 dir=d2^1;
9100 2111 return true;
9101 80892 }
9102
9103 1024382 void eLeever::draw(BITMAP *dest)
9104 {
9105 // cs=d->cset;
9106 1024382 cs=dcset;
9107 1024382 update_enemy_frame();
9108
3/4
✓ Branch 0 taken 1024027 times.
✓ Branch 1 taken 355 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1024027 times.
1024382 if(!fallclk&&!drownclk)
9109 {
9110
2/2
✓ Branch 0 taken 637088 times.
✓ Branch 1 taken 386939 times.
1024027 switch(misc)
9111 {
9112 case -1:
9113 case 0:
9114 386939 return;
9115 }
9116 637088 }
9117
9118 637443 enemy::draw(dest);
9119 1024382 }
9120
9121 998 eWallM::eWallM(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9122 998 {
9123 998 hashero=false;
9124 //nets+1000;
9125
1/4
✓ Branch 0 taken 998 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
998 if (SIZEflags != 0) init_size_flags();;
9126 998 }
9127
9128 504762 bool eWallM::animate(int32_t index)
9129 {
9130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 504762 times.
504762 if(switch_hooked) return enemy::animate(index);
9131
2/4
✓ Branch 0 taken 504762 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 504762 times.
504762 if(fallclk||drownclk)
9132 {
9133 return enemy::animate(index);
9134 }
9135
2/2
✓ Branch 0 taken 9856 times.
✓ Branch 1 taken 494906 times.
504762 if(dying)
9136 9856 return Dead(index);
9137
9138
2/2
✓ Branch 0 taken 463930 times.
✓ Branch 1 taken 30976 times.
494906 if(clk==0)
9139 {
9140 30976 removearmos(x,y);
9141 30976 }
9142
9143 494906 hxofs=1000;
9144
2/2
✓ Branch 0 taken 117732 times.
✓ Branch 1 taken 377174 times.
494906 if(misc==0) //inside wall, ready to spawn?
9145 {
9146
4/4
✓ Branch 0 taken 228512 times.
✓ Branch 1 taken 148662 times.
✓ Branch 2 taken 16723 times.
✓ Branch 3 taken 211789 times.
377174 if(frame-wallm_load_clk>80 && clk>=0)
9147 {
9148 211789 int32_t wall=hero_on_wall();
9149 211789 int32_t wallm_cnt=0;
9150
9151
2/2
✓ Branch 0 taken 1670618 times.
✓ Branch 1 taken 211789 times.
1882407 for(int32_t i=0; i<guys.Count(); i++)
9152
2/2
✓ Branch 0 taken 657527 times.
✓ Branch 1 taken 1013091 times.
2683709 if(((enemy*)guys.spr(i))->type==eeWALLM)
9153 {
9154 1013091 int32_t m=((enemy*)guys.spr(i))->misc;
9155
9156
4/4
✓ Branch 0 taken 50104 times.
✓ Branch 1 taken 962987 times.
✓ Branch 2 taken 36738 times.
✓ Branch 3 taken 13366 times.
1013091 if(m && ((enemy*)guys.spr(i))->clk3==(wall^1))
9157 {
9158 13366 ++wallm_cnt;
9159 13366 }
9160 1013091 }
9161
9162
2/2
✓ Branch 0 taken 210948 times.
✓ Branch 1 taken 841 times.
211789 if(wall>0)
9163 {
9164 841 --wall;
9165 841 misc=1; //emerging from the wall?
9166 841 clk2=0;
9167 841 clk3=wall^1;
9168 841 wallm_load_clk=frame;
9169
9170
2/2
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 327 times.
841 if(wall<=down)
9171 {
9172
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 423 times.
514 if(HeroDir()==left)
9173 91 dir=right;
9174 else
9175 423 dir=left;
9176 514 }
9177 else
9178 {
9179
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 261 times.
327 if(HeroDir()==up)
9180 66 dir=down;
9181 else
9182 261 dir=up;
9183 }
9184
9185
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 231 times.
✓ Branch 2 taken 283 times.
✓ Branch 3 taken 223 times.
✓ Branch 4 taken 104 times.
841 switch(wall)
9186 {
9187 case up:
9188 231 y=0;
9189 231 break;
9190
9191 case down:
9192 283 y=160;
9193 283 break;
9194
9195 case left:
9196 223 x=0;
9197 223 break;
9198
9199 case right:
9200 104 x=240;
9201 104 break;
9202 }
9203
9204
9205
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 261 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 423 times.
✓ Branch 4 taken 91 times.
841 switch(dir)
9206 {
9207 case up:
9208 261 y=(HeroY()+48-(wallm_cnt&1)*12);
9209 261 flip=wall&1;
9210 261 break;
9211
9212 case down:
9213 66 y=(HeroY()-48+(wallm_cnt&1)*12);
9214 66 flip=((wall&1)^1)+2;
9215 66 break;
9216
9217 case left:
9218 423 x=(HeroX()+48-(wallm_cnt&1)*12);
9219 423 flip=(wall==up?2:0)+1;
9220 423 break;
9221
9222 case right:
9223 91 x=(HeroX()-48+(wallm_cnt&1)*12);
9224 91 flip=(wall==up?2:0);
9225 91 break;
9226 }
9227
9228 841 }
9229 211789 }
9230 377174 }
9231 else
9232 117732 wallm_crawl();
9233
9234 494906 return enemy::animate(index);
9235 504762 }
9236
9237 117732 void eWallM::wallm_crawl()
9238 {
9239 117732 bool w=watch;
9240 117732 hxofs=0;
9241
9242
2/2
✓ Branch 0 taken 810 times.
✓ Branch 1 taken 116922 times.
117732 if(slide())
9243 {
9244 810 return;
9245 }
9246
9247 // if(dying || watch || (!hashero && stunclk))
9248
6/8
✓ Branch 0 taken 116922 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115593 times.
✓ Branch 3 taken 1329 times.
✓ Branch 4 taken 101047 times.
✓ Branch 5 taken 14546 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 101047 times.
116922 if(dying || (!hashero && ( stunclk || frozenclock )))
9249 {
9250 14546 return;
9251 }
9252
9253 102376 watch=false;
9254 102376 ++clk2;
9255 // Misc1: slightly different movement
9256 102376 float tmpmisc3 = ((40.0/(int32_t)dstep)*40);
9257
9258 //int32_t tmpmisc = int32_t((40.0/dstep)*40);
9259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102376 times.
102376 misc=(clk2/(dmisc1==1?40:(int32_t)tmpmisc3))+1;
9260
5/6
✓ Branch 0 taken 6217 times.
✓ Branch 1 taken 96159 times.
✓ Branch 2 taken 4491 times.
✓ Branch 3 taken 1726 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4491 times.
102376 if(w&&misc>=3&&misc<=5)
9261 {
9262 4491 --clk2;
9263 4491 }
9264
9265
4/4
✓ Branch 0 taken 39396 times.
✓ Branch 1 taken 52852 times.
✓ Branch 2 taken 9984 times.
✓ Branch 3 taken 144 times.
102376 switch(misc)
9266 {
9267 case 1:
9268 case 2:
9269 52852 zc_swap(dir,clk3);
9270 52852 move(step);
9271 52852 zc_swap(dir,clk3);
9272 52852 break;
9273
9274 case 3:
9275 case 4:
9276 case 5:
9277
2/2
✓ Branch 0 taken 4491 times.
✓ Branch 1 taken 34905 times.
39396 if(w)
9278 {
9279 4491 watch=w;
9280 4491 return;
9281 }
9282
9283 34905 move(step);
9284 34905 break;
9285
9286 case 6:
9287 case 7:
9288 9984 zc_swap(dir,clk3);
9289 9984 dir^=1;
9290 9984 move(step);
9291 9984 dir^=1;
9292 9984 zc_swap(dir,clk3);
9293 9984 break;
9294
9295 default:
9296 144 misc=0;
9297 144 break;
9298 }
9299
9300 97885 watch=w;
9301 117732 }
9302
9303 9 void eWallM::grabhero()
9304 {
9305 9 hashero=true;
9306 9 superman=1;
9307 9 }
9308
9309 507147 void eWallM::draw(BITMAP *dest)
9310 {
9311 507147 dummy_bool[1]=hashero;
9312 507147 update_enemy_frame();
9313
9314
4/6
✓ Branch 0 taken 377966 times.
✓ Branch 1 taken 129181 times.
✓ Branch 2 taken 377966 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 377966 times.
507147 if(misc>0 || fallclk||drownclk)
9315 {
9316 129181 masked_draw(dest,16,playing_field_offset+16,224,144);
9317 129181 }
9318
9319 // enemy::draw(dest);
9320 // tile = clk&8 ? 128:129;
9321 507147 }
9322
9323 bool eWallM::isSubmerged() const
9324 {
9325 return ( !misc );
9326 }
9327
9328 1640 eTrap::eTrap(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9329 1640 {
9330
1/2
✓ Branch 0 taken 1640 times.
✗ Branch 1 not taken.
1640 ox=x; //original x
9331
1/2
✓ Branch 0 taken 1640 times.
✗ Branch 1 not taken.
1640 oy=y; //original y
9332
2/2
✓ Branch 0 taken 1474 times.
✓ Branch 1 taken 166 times.
1640 if(get_qr(qr_TRAPPOSFIX))
9333 {
9334
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 166 times.
✓ Branch 2 taken 166 times.
✗ Branch 3 not taken.
166 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9335 166 }
9336
9337 1640 mainguy=false;
9338
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1640 times.
1640 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9339 //nets+420;
9340 1640 dummy_int[1]=0;
9341
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1640 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1640 if (SIZEflags != 0) init_size_flags();;
9342 1640 }
9343
9344 1042165 bool eTrap::animate(int32_t index)
9345 {
9346
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1042165 times.
1042165 if(switch_hooked) return enemy::animate(index);
9347
2/4
✓ Branch 0 taken 1042165 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1042165 times.
1042165 if(fallclk||drownclk) return enemy::animate(index);
9348
2/2
✓ Branch 0 taken 1020511 times.
✓ Branch 1 taken 21654 times.
1042165 if(clk<0)
9349 21654 return enemy::animate(index);
9350
9351
2/2
✓ Branch 0 taken 955962 times.
✓ Branch 1 taken 64549 times.
1020511 if(clk==0)
9352 {
9353 64549 removearmos(x,y);
9354 64549 }
9355
9356
2/2
✓ Branch 0 taken 319209 times.
✓ Branch 1 taken 701302 times.
1020511 if(misc==0) // waiting
9357 {
9358 701302 ox = x;
9359 701302 oy = y;
9360 double _MSVC2022_tmp1, _MSVC2022_tmp2;
9361 701302 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
9362
9363
4/4
✓ Branch 0 taken 241777 times.
✓ Branch 1 taken 459525 times.
✓ Branch 2 taken 133516 times.
✓ Branch 3 taken 108261 times.
701302 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
9364 {
9365 108261 dir=down;
9366 108261 }
9367
4/4
✓ Branch 0 taken 393308 times.
✓ Branch 1 taken 199733 times.
✓ Branch 2 taken 133516 times.
✓ Branch 3 taken 259792 times.
593041 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
9368 {
9369 259792 dir=right;
9370 259792 }
9371
4/4
✓ Branch 0 taken 212039 times.
✓ Branch 1 taken 121210 times.
✓ Branch 2 taken 133516 times.
✓ Branch 3 taken 78523 times.
333249 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
9372 {
9373 78523 dir=up;
9374 78523 }
9375 else
9376 {
9377 254726 dir=left;
9378 }
9379
9380 701302 int32_t d2=lined_up(15,true);
9381
9382
4/4
✓ Branch 0 taken 268741 times.
✓ Branch 1 taken 432561 times.
✓ Branch 2 taken 1107234 times.
✓ Branch 3 taken 405932 times.
1095295 if(((d2<left || d2 > right) && (dmisc1==1)) ||
9383
2/2
✓ Branch 0 taken 232564 times.
✓ Branch 1 taken 173368 times.
405932 ((d2>down) && (dmisc1==2)) ||
9384
2/2
✓ Branch 0 taken 187069 times.
✓ Branch 1 taken 81901 times.
173368 ((d2>right) && (!dmisc1)) ||
9385
2/2
✓ Branch 0 taken 393993 times.
✓ Branch 1 taken 125023 times.
268970 ((d2<l_up) && (dmisc1==4)) ||
9386
3/4
✓ Branch 0 taken 393993 times.
✓ Branch 1 taken 268970 times.
✓ Branch 2 taken 393993 times.
✗ Branch 3 not taken.
125023 ((d2!=r_up) && (d2!=l_down) && (dmisc1==6)) ||
9387
3/4
✓ Branch 0 taken 393993 times.
✓ Branch 1 taken 125023 times.
✓ Branch 2 taken 393993 times.
✗ Branch 3 not taken.
268970 ((d2!=l_up) && (d2!=r_down) && (dmisc1==8)))
9388 {
9389 2521777 d2=-1;
9390 2521777 }
9391
9392
4/4
✓ Branch 0 taken 20708 times.
✓ Branch 1 taken 411624 times.
✓ Branch 2 taken 18593 times.
✓ Branch 3 taken 2115 times.
432332 if(d2!=-1 && trapmove(d2))
9393 {
9394 2115 dir=d2;
9395 2115 misc=1;
9396 2115 clk2=(dir==down)?3:0;
9397 2115 }
9398 432332 }
9399
9400
2/2
✓ Branch 0 taken 662006 times.
✓ Branch 1 taken 89535 times.
751541 if(misc==1) // charging
9401 {
9402 89535 clk2=(clk2+1)&3;
9403 89535 step=(clk2==3)?1:2;
9404
9405
4/4
✓ Branch 0 taken 88731 times.
✓ Branch 1 taken 804 times.
✓ Branch 2 taken 1105 times.
✓ Branch 3 taken 87626 times.
89535 if(!trapmove(dir) || clip())
9406 {
9407 1909 misc=2;
9408
9409
1/2
✓ Branch 0 taken 1909 times.
✗ Branch 1 not taken.
1909 if(dir<l_up)
9410 {
9411 1909 dir=dir^1;
9412 1909 }
9413 else
9414 {
9415 dir=dir^3;
9416 }
9417 1909 }
9418 else
9419 {
9420 87626 sprite::move(step);
9421 }
9422 89535 }
9423
9424
2/2
✓ Branch 0 taken 517843 times.
✓ Branch 1 taken 233698 times.
751541 if(misc==2) // retreating
9425 {
9426 233698 step=(++clk2&1)?1:0;
9427
9428
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 39011 times.
✓ Branch 2 taken 80947 times.
✓ Branch 3 taken 29129 times.
✓ Branch 4 taken 84611 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
233698 switch(dir)
9429 {
9430 case up:
9431
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 38739 times.
39011 if(int32_t(y)<=oy) goto trap_rest;
9432 38739 else sprite::move(step);
9433
9434 38739 break;
9435
9436 case left:
9437
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 80555 times.
80947 if(int32_t(x)<=ox) goto trap_rest;
9438 80555 else sprite::move(step);
9439
9440 80555 break;
9441
9442 case down:
9443
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 28905 times.
29129 if(int32_t(y)>=oy) goto trap_rest;
9444 28905 else sprite::move(step);
9445
9446 28905 break;
9447
9448 case right:
9449
2/2
✓ Branch 0 taken 435 times.
✓ Branch 1 taken 84176 times.
84611 if(int32_t(x)>=ox) goto trap_rest;
9450 84176 else sprite::move(step);
9451
9452 84176 break;
9453
9454 case l_up:
9455 if(int32_t(x)<=ox && int32_t(y)<=oy) goto trap_rest;
9456 else sprite::move(step);
9457
9458 break;
9459
9460 case r_up:
9461 if(int32_t(x)>=ox && int32_t(y)<=oy) goto trap_rest;
9462 else sprite::move(step);
9463
9464 break;
9465
9466 case l_down:
9467 if(int32_t(x)<=ox && int32_t(y)>=oy) goto trap_rest;
9468 else sprite::move(step);
9469
9470 break;
9471
9472 case r_down:
9473 if(int32_t(x)>=ox && int32_t(y)>=oy) goto trap_rest;
9474 else sprite::move(step);
9475
9476 break;
9477 trap_rest:
9478 {
9479 1323 x=ox;
9480 1323 y=oy;
9481 1323 misc=0;
9482 }
9483 1323 }
9484 233698 }
9485
9486 751541 return enemy::animate(index);
9487 773195 }
9488
9489 110243 bool eTrap::trapmove(int32_t ndir)
9490 {
9491
2/2
✓ Branch 0 taken 80479 times.
✓ Branch 1 taken 29764 times.
110243 if(get_qr(qr_MEANTRAPS))
9492 {
9493 80479 mapscr* scr = get_scr(screen_spawned);
9494
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 79139 times.
80479 if(scr->flags2&fFLOATTRAPS)
9495 1340 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9496
9497 79139 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9498 }
9499
9500
6/6
✓ Branch 0 taken 14672 times.
✓ Branch 1 taken 15092 times.
✓ Branch 2 taken 7198 times.
✓ Branch 3 taken 7474 times.
✓ Branch 4 taken 2468 times.
✓ Branch 5 taken 4730 times.
29764 if(oy==80 && !(ndir==left || ndir == right))
9501 4730 return false;
9502
9503
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 25034 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25034 if(ox==128 && !(ndir==up || ndir==down))
9504 return false;
9505
9506
3/4
✓ Branch 0 taken 7496 times.
✓ Branch 1 taken 17538 times.
✓ Branch 2 taken 7496 times.
✗ Branch 3 not taken.
25034 if(oy<80 && ndir==up)
9507 return false;
9508
9509
3/4
✓ Branch 0 taken 7596 times.
✓ Branch 1 taken 17438 times.
✓ Branch 2 taken 7596 times.
✗ Branch 3 not taken.
25034 if(oy>80 && ndir==down)
9510 return false;
9511
9512
4/4
✓ Branch 0 taken 14455 times.
✓ Branch 1 taken 10579 times.
✓ Branch 2 taken 9733 times.
✓ Branch 3 taken 4722 times.
25034 if(ox<128 && ndir==left)
9513 4722 return false;
9514
9515
4/4
✓ Branch 0 taken 10579 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 9866 times.
✓ Branch 3 taken 713 times.
20312 if(ox>128 && ndir==right)
9516 713 return false;
9517
9518
5/6
✓ Branch 0 taken 9733 times.
✓ Branch 1 taken 9866 times.
✓ Branch 2 taken 4067 times.
✓ Branch 3 taken 5666 times.
✓ Branch 4 taken 4067 times.
✗ Branch 5 not taken.
19599 if(ox<128 && oy<80 && ndir==l_up)
9519 return false;
9520
9521
5/6
✓ Branch 0 taken 9733 times.
✓ Branch 1 taken 9866 times.
✓ Branch 2 taken 3911 times.
✓ Branch 3 taken 5822 times.
✓ Branch 4 taken 3911 times.
✗ Branch 5 not taken.
19599 if(ox<128 && oy>80 && ndir==l_down)
9522 return false;
9523
9524
5/6
✓ Branch 0 taken 9866 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 3429 times.
✓ Branch 3 taken 6437 times.
✓ Branch 4 taken 3429 times.
✗ Branch 5 not taken.
19599 if(ox>128 && oy<80 && ndir==r_up)
9525 return false;
9526
9527
5/6
✓ Branch 0 taken 9866 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 3685 times.
✓ Branch 3 taken 6181 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3685 times.
19599 if(ox>128 && oy>80 && ndir==r_down)
9528 return false;
9529
9530 19599 return true;
9531 110243 }
9532
9533 88731 bool eTrap::clip()
9534 {
9535
2/2
✓ Branch 0 taken 43022 times.
✓ Branch 1 taken 45709 times.
88731 if(get_qr(qr_MEANPLACEDTRAPS))
9536 {
9537
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 5792 times.
✓ Branch 2 taken 8656 times.
✓ Branch 3 taken 16039 times.
✓ Branch 4 taken 15222 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
45709 switch(dir)
9538 {
9539 case up:
9540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5792 times.
5792 if(y<=0) return true;
9541
9542 5792 break;
9543
9544 case down:
9545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8656 times.
8656 if(y>=world_h-16) return true;
9546
9547 8656 break;
9548
9549 case left:
9550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16039 times.
16039 if(x<=0) return true;
9551
9552 16039 break;
9553
9554 case right:
9555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15222 times.
15222 if(x>=world_w-16) return true;
9556
9557 15222 break;
9558
9559 case l_up:
9560 if(y<=0||x<=0) return true;
9561
9562 break;
9563
9564 case l_down:
9565 if(y>=world_h-16||x<=0) return true;
9566
9567 break;
9568
9569 case r_up:
9570 if(y<=0||x>=world_w-16) return true;
9571
9572 break;
9573
9574 case r_down:
9575 if(y>=world_h-16||x>=world_w-16) return true;
9576
9577 break;
9578 }
9579
9580 45709 return false;
9581 }
9582 else
9583 {
9584
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 4882 times.
✓ Branch 2 taken 5449 times.
✓ Branch 3 taken 16755 times.
✓ Branch 4 taken 15936 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
43022 switch(dir)
9585 {
9586 case up:
9587
4/4
✓ Branch 0 taken 4828 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 4641 times.
✓ Branch 3 taken 187 times.
4882 if(oy>80 && y<=86) return true;
9588
9589 4695 break;
9590
9591 case down:
9592
4/4
✓ Branch 0 taken 5368 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 5172 times.
✓ Branch 3 taken 196 times.
5449 if(oy<80 && y>=80) return true;
9593
9594 5253 break;
9595
9596 case left:
9597
4/4
✓ Branch 0 taken 16665 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 16286 times.
✓ Branch 3 taken 379 times.
16755 if(ox>128 && x<=124) return true;
9598
9599 16376 break;
9600
9601 case right:
9602
4/4
✓ Branch 0 taken 15855 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 15512 times.
✓ Branch 3 taken 343 times.
15936 if(ox<120 && x>=116) return true;
9603
9604 15593 break;
9605
9606 case l_up:
9607 if(oy>80 && y<=86 && ox>128 && x<=124) return true;
9608
9609 break;
9610
9611 case l_down:
9612 if(oy<80 && y>=80 && ox>128 && x<=124) return true;
9613
9614 break;
9615
9616 case r_up:
9617 if(oy>80 && y<=86 && ox<120 && x>=116) return true;
9618
9619 break;
9620
9621 case r_down:
9622 if(oy<80 && y>=80 && ox<120 && x>=116) return true;
9623
9624 break;
9625 }
9626
9627 41917 return false;
9628 }
9629 88731 }
9630
9631 1061079 void eTrap::draw(BITMAP *dest)
9632 {
9633 1061079 update_enemy_frame();
9634 1061079 enemy::draw(dest);
9635 1061079 }
9636
9637 5705 int32_t eTrap::takehit(weapon*,weapon*)
9638 {
9639 5705 return 0;
9640 }
9641
9642 832 eTrap2::eTrap2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9643 832 {
9644 832 lasthit=-1;
9645 832 lasthitclk=0;
9646 832 mainguy=false;
9647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9648
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 step=2;
9649
3/6
✓ Branch 0 taken 433 times.
✓ Branch 1 taken 399 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 433 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
832 if(dmisc1==1 || (dmisc1==0 && zc_oldrand()&2))
9650 {
9651
2/4
✓ Branch 0 taken 399 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399 times.
✗ Branch 3 not taken.
399 dir=(x<=112)?right:left;
9652 399 }
9653 else
9654 {
9655
2/4
✓ Branch 0 taken 433 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 433 times.
✗ Branch 3 not taken.
433 dir=(y<=72)?down:up;
9656 }
9657
9658
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 72 times.
832 if(get_qr(qr_TRAPPOSFIX))
9659 {
9660
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
72 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9661 72 }
9662
9663 //nets+((id==eTRAP_LR)?540:520);
9664 832 dummy_int[1]=0;
9665
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
832 if (SIZEflags != 0) init_size_flags();;
9666 832 }
9667
9668 346559 bool eTrap2::animate(int32_t index)
9669 {
9670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 346559 times.
346559 if(switch_hooked) return enemy::animate(index);
9671
2/4
✓ Branch 0 taken 346559 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 346559 times.
346559 if(fallclk||drownclk) return enemy::animate(index);
9672
2/2
✓ Branch 0 taken 335533 times.
✓ Branch 1 taken 11026 times.
346559 if(clk<0)
9673 11026 return enemy::animate(index);
9674
9675
2/2
✓ Branch 0 taken 21385 times.
✓ Branch 1 taken 314148 times.
335533 if(clk==0)
9676 {
9677 21385 removearmos(x,y);
9678 21385 }
9679
9680
2/2
✓ Branch 0 taken 211207 times.
✓ Branch 1 taken 124326 times.
335533 if(!get_qr(qr_PHANTOMPLACEDTRAPS))
9681 {
9682
2/2
✓ Branch 0 taken 11074 times.
✓ Branch 1 taken 113252 times.
124326 if(lasthitclk>0)
9683 {
9684 11074 --lasthitclk;
9685 11074 }
9686 else
9687 {
9688 113252 lasthit=-1;
9689 }
9690
9691 124326 bool hitenemy=false;
9692
9693
2/2
✓ Branch 0 taken 864860 times.
✓ Branch 1 taken 124326 times.
989186 for(int32_t j=0; j<guys.Count(); j++)
9694 {
9695
4/4
✓ Branch 0 taken 740534 times.
✓ Branch 1 taken 124326 times.
✓ Branch 2 taken 10183 times.
✓ Branch 3 taken 730351 times.
864860 if((j!=index) && (lasthit!=j))
9696 {
9697
2/2
✓ Branch 0 taken 726682 times.
✓ Branch 1 taken 3669 times.
730351 if(hit(guys.spr(j)))
9698 {
9699 3669 lasthit=j;
9700 3669 lasthitclk=10;
9701 3669 hitenemy=true;
9702 3669 guys.spr(j)->lasthit=index;
9703 3669 guys.spr(j)->lasthitclk=10;
9704 // guys.spr(j)->dir=guys.spr(j)->dir^1;
9705 3669 }
9706 730351 }
9707 864860 }
9708
9709
5/6
✓ Branch 0 taken 121171 times.
✓ Branch 1 taken 3155 times.
✓ Branch 2 taken 121171 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2831 times.
✓ Branch 5 taken 118340 times.
124326 if(!trapmove(dir) || clip() || hitenemy)
9710 {
9711
3/4
✓ Branch 0 taken 2831 times.
✓ Branch 1 taken 3155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2831 times.
5986 if(!trapmove(dir) || clip())
9712 {
9713 3155 lasthit=-1;
9714 3155 lasthitclk=0;
9715 3155 }
9716
9717
2/2
✓ Branch 0 taken 5624 times.
✓ Branch 1 taken 362 times.
5986 if(get_qr(qr_MORESOUNDS))
9718 362 sfx(WAV_ZN1TAP,pan(x));
9719
9720 5986 dir=dir^1;
9721 5986 }
9722
9723 124326 sprite::move(step);
9724 124326 }
9725 else
9726 {
9727
3/4
✓ Branch 0 taken 204288 times.
✓ Branch 1 taken 6919 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 204288 times.
211207 if(!trapmove(dir) || clip())
9728 {
9729
2/2
✓ Branch 0 taken 5398 times.
✓ Branch 1 taken 1521 times.
6919 if(get_qr(qr_MORESOUNDS))
9730 1521 sfx(WAV_ZN1TAP,pan(x));
9731
9732 6919 dir=dir^1;
9733 6919 }
9734
9735 211207 sprite::move(step);
9736 }
9737
9738 335533 return enemy::animate(index);
9739 346559 }
9740
9741 341519 bool eTrap2::trapmove(int32_t ndir)
9742 {
9743 341519 mapscr* scr = get_scr(screen_spawned);
9744
2/2
✓ Branch 0 taken 1878 times.
✓ Branch 1 taken 339641 times.
341519 if(scr->flags2&fFLOATTRAPS)
9745 1878 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9746
9747 339641 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9748 341519 }
9749
9750 328290 bool eTrap2::clip()
9751 {
9752
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 88320 times.
✓ Branch 2 taken 89029 times.
✓ Branch 3 taken 75153 times.
✓ Branch 4 taken 75788 times.
328290 switch(dir)
9753 {
9754 case up:
9755
1/2
✓ Branch 0 taken 88320 times.
✗ Branch 1 not taken.
88320 if(y<=0) return true;
9756
9757 88320 break;
9758
9759 case down:
9760
1/2
✓ Branch 0 taken 89029 times.
✗ Branch 1 not taken.
89029 if(y>=world_h-16) return true;
9761
9762 89029 break;
9763
9764 case left:
9765
1/2
✓ Branch 0 taken 75153 times.
✗ Branch 1 not taken.
75153 if(x<=0) return true;
9766
9767 75153 break;
9768
9769 case right:
9770
1/2
✓ Branch 0 taken 75788 times.
✗ Branch 1 not taken.
75788 if(x>=world_w-16) return true;
9771
9772 75788 break;
9773 }
9774
9775 328290 return false;
9776 328290 }
9777
9778 350933 void eTrap2::draw(BITMAP *dest)
9779 {
9780 350933 update_enemy_frame();
9781 350933 enemy::draw(dest);
9782 350933 }
9783
9784 3169 int32_t eTrap2::takehit(weapon*,weapon*)
9785 {
9786 3169 return 0;
9787 }
9788
9789 354 eRock::eRock(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9790 354 {
9791 //do not show "enemy appering" anim -DD
9792 354 clk=0;
9793 354 mainguy=false;
9794 354 clk2=-14;
9795 //Enemy Editor Size Tab
9796
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 init_size_flags();
9797 //nets+1640;
9798 354 }
9799
9800 354 void eRock::init_size_flags()
9801 {
9802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
354 if ((d->SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
9803 354 else hxofs = -2;
9804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
354 if ((d->SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
9805 354 else hyofs = -2;
9806
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
9807 354 else hit_width = 20;
9808
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
9809 354 else hit_height = 20;
9810
9811
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
354 if (((d->SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
9812
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
354 if (((d->SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
9813
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
9814
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
9815
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
9816 {
9817 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
9818 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
9819 }
9820
9821
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
9822 354 }
9823
9824 121997 bool eRock::animate(int32_t index)
9825 {
9826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121997 times.
121997 if(switch_hooked) return enemy::animate(index);
9827
2/4
✓ Branch 0 taken 121997 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 121997 times.
121997 if(fallclk||drownclk) return enemy::animate(index);
9828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121997 times.
121997 if(dying)
9829 return Dead(index);
9830
9831
2/2
✓ Branch 0 taken 113621 times.
✓ Branch 1 taken 8376 times.
121997 if(clk==0)
9832 {
9833 8376 removearmos(x,y);
9834 8376 }
9835
9836
2/2
✓ Branch 0 taken 121300 times.
✓ Branch 1 taken 697 times.
121997 if(++clk2==0) // start it
9837 {
9838 697 x=zc_oldrand()&0xF0;
9839 697 y=0;
9840 697 clk3=0;
9841 697 clk2=zc_oldrand()&15;
9842 697 }
9843
9844
2/2
✓ Branch 0 taken 22820 times.
✓ Branch 1 taken 99177 times.
121997 if(clk2>16) // move it
9845 {
9846
2/2
✓ Branch 0 taken 95747 times.
✓ Branch 1 taken 3430 times.
99177 if(clk3<=0) // start bounce
9847 {
9848 3430 dir=zc_oldrand()&1;
9849
9850
2/2
✓ Branch 0 taken 3063 times.
✓ Branch 1 taken 367 times.
3430 if(x<32) dir=1;
9851
9852
2/2
✓ Branch 0 taken 3133 times.
✓ Branch 1 taken 297 times.
3430 if(x>208) dir=0;
9853 3430 }
9854
9855
2/2
✓ Branch 0 taken 95993 times.
✓ Branch 1 taken 3184 times.
99177 if(clk3<13+16)
9856 {
9857 95993 x += dir ? 1 : -1; //right, left
9858 95993 dummy_int[1]=dir;
9859
9860
2/2
✓ Branch 0 taken 6852 times.
✓ Branch 1 taken 89141 times.
95993 if(clk3<2)
9861 {
9862 6852 y-=2; //up
9863 6852 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9864 6852 }
9865
2/2
✓ Branch 0 taken 10208 times.
✓ Branch 1 taken 78933 times.
89141 else if(clk3<5)
9866 {
9867 10208 y--; //up
9868 10208 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9869 10208 }
9870
2/2
✓ Branch 0 taken 10135 times.
✓ Branch 1 taken 68798 times.
78933 else if(clk3<8)
9871 {
9872 10135 dummy_int[2]=(dummy_int[1]==1)?right:left;
9873 10135 }
9874
2/2
✓ Branch 0 taken 10058 times.
✓ Branch 1 taken 58740 times.
68798 else if(clk3<11)
9875 {
9876 10058 y++; //down
9877 10058 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9878 10058 }
9879 else
9880 {
9881 58740 y+=2; //down
9882 58740 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9883 }
9884
9885 95993 ++clk3;
9886 95993 }
9887
2/2
✓ Branch 0 taken 2761 times.
✓ Branch 1 taken 423 times.
3184 else if(y<world_h)
9888 2761 clk3=0; // next bounce
9889 else
9890 423 clk2 = -(zc_oldrand()&63); // back to top
9891 99177 }
9892
9893 121997 return enemy::animate(index);
9894 121997 }
9895
9896 51441 void eRock::drawshadow(BITMAP *dest, bool translucent)
9897 {
9898
2/2
✓ Branch 0 taken 7191 times.
✓ Branch 1 taken 44250 times.
51441 if(clk2>=0)
9899 {
9900 44250 int32_t tempy=yofs;
9901 44250 flip = 0;
9902 44250 int32_t fdiv = frate/4;
9903
1/2
✓ Branch 0 taken 44250 times.
✗ Branch 1 not taken.
44250 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
9904
1/2
✓ Branch 0 taken 44250 times.
✗ Branch 1 not taken.
44250 int32_t f2=get_qr(qr_NEWENEMYTILES)?
9905 44250 efrate:((clk>=(frate>>1))?1:0);
9906 44250 shadowtile = wpnsbuf[spr_shadow].tile+f2;
9907
9908 44250 yofs+=8;
9909
6/6
✓ Branch 0 taken 20474 times.
✓ Branch 1 taken 23776 times.
✓ Branch 2 taken 38962 times.
✓ Branch 3 taken 5288 times.
✓ Branch 4 taken 19073 times.
✓ Branch 5 taken 19889 times.
44250 yofs+=zc_max(0,zc_min(29-clk3,clk3));
9910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44250 times.
44250 if(!shadow_overpit(this))
9911 44250 sprite::drawshadow(dest, translucent);
9912 44250 yofs=tempy;
9913 44250 }
9914 51441 }
9915
9916 122078 void eRock::draw(BITMAP *dest)
9917 {
9918
4/6
✓ Branch 0 taken 17035 times.
✓ Branch 1 taken 105043 times.
✓ Branch 2 taken 17035 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 17035 times.
122078 if(clk2>=0 || fallclk||drownclk)
9919 {
9920 105043 int32_t tempdir=dir;
9921 105043 dir=dummy_int[2];
9922 105043 update_enemy_frame();
9923 105043 enemy::draw(dest);
9924 105043 dir=tempdir;
9925 105043 }
9926 122078 }
9927
9928 1014 int32_t eRock::takehit(weapon*,weapon*)
9929 {
9930 1014 return 0;
9931 }
9932
9933 30 eBoulder::eBoulder(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9934 30 {
9935 30 clk=0;
9936 30 mainguy=false;
9937 30 clk2=-14;
9938
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 init_size_flags();
9939 //nets+1680;
9940 30 }
9941
9942 4440 bool eBoulder::animate(int32_t index)
9943 {
9944
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(switch_hooked) return enemy::animate(index);
9945
2/4
✓ Branch 0 taken 4440 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4440 times.
4440 if(fallclk||drownclk) return enemy::animate(index);
9946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(dying)
9947 return Dead(index);
9948
9949
2/2
✓ Branch 0 taken 4150 times.
✓ Branch 1 taken 290 times.
4440 if(clk==0)
9950 {
9951 290 removearmos(x,y);
9952 290 }
9953
9954 zfix *vert;
9955
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
✓ Branch 2 taken 4440 times.
✗ Branch 3 not taken.
4440 vert = (moveflags & move_use_fake_z) ? &fakez : get_qr(qr_ENEMIESZAXIS) ? &z : &y;
9956
9957
2/2
✓ Branch 0 taken 4408 times.
✓ Branch 1 taken 32 times.
4440 if(++clk2==0) // start it
9958 {
9959 32 x=zc_oldrand()&0xF0;
9960 32 y=-32;
9961 32 clk3=0;
9962 32 clk2=zc_oldrand()&15;
9963 32 }
9964
9965
2/2
✓ Branch 0 taken 842 times.
✓ Branch 1 taken 3598 times.
4440 if(clk2>16) // move it
9966 {
9967
2/2
✓ Branch 0 taken 3467 times.
✓ Branch 1 taken 131 times.
3598 if(clk3<=0) // start bounce
9968 {
9969 131 dir=zc_oldrand()&1;
9970
9971
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 10 times.
131 if(x<32) dir=1;
9972
9973
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(x>208) dir=0;
9974 131 }
9975
9976
2/2
✓ Branch 0 taken 3487 times.
✓ Branch 1 taken 111 times.
3598 if(clk3<13+16)
9977 {
9978 3487 x += dir ? 1 : -1; //right, left
9979 3487 dummy_int[1]=dir;
9980
9981
2/2
✓ Branch 0 taken 261 times.
✓ Branch 1 taken 3226 times.
3487 if(clk3<2)
9982 {
9983 261 y-=2; //up
9984 261 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9985 261 }
9986
2/2
✓ Branch 0 taken 382 times.
✓ Branch 1 taken 2844 times.
3226 else if(clk3<5)
9987 {
9988 382 y--; //up
9989 382 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9990 382 }
9991
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 2468 times.
2844 else if(clk3<8)
9992 {
9993 376 dummy_int[2]=(dummy_int[1]==1)?right:left;
9994 376 }
9995
2/2
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 2101 times.
2468 else if(clk3<11)
9996 {
9997 367 y++; //down
9998 367 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9999 367 }
10000 else
10001 {
10002 2101 y+=2; //down
10003 2101 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10004 }
10005
10006 3487 ++clk3;
10007 3487 }
10008
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 10 times.
111 else if(y<176)
10009 101 clk3=0; // next bounce
10010 else
10011 10 clk2 = -(zc_oldrand()&63); // back to top
10012 3598 }
10013
10014 4440 return enemy::animate(index);
10015 4440 }
10016
10017 4440 void eBoulder::drawshadow(BITMAP *dest, bool translucent)
10018 {
10019
2/2
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
4440 if(clk2>=0)
10020 {
10021 3868 int32_t tempy=yofs;
10022 3868 flip = 0;
10023 3868 int32_t f2=((clk<<2)/frate)<<1;
10024 3868 shadowtile = wpnsbuf[spr_shadow].tile+f2;
10025
6/6
✓ Branch 0 taken 1729 times.
✓ Branch 1 taken 2139 times.
✓ Branch 2 taken 3356 times.
✓ Branch 3 taken 512 times.
✓ Branch 4 taken 1618 times.
✓ Branch 5 taken 1738 times.
3868 yofs+=zc_max(0,zc_min(29-clk3,clk3));
10026
10027 3868 yofs+=8;
10028 3868 xofs-=8;
10029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10030 3868 sprite::drawshadow(dest, translucent);
10031 3868 xofs+=16;
10032 3868 ++shadowtile;
10033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10034 3868 sprite::drawshadow(dest, translucent);
10035 3868 yofs+=16;
10036 3868 shadowtile+=20;
10037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10038 3868 sprite::drawshadow(dest, translucent);
10039 3868 xofs-=16;
10040 3868 --shadowtile;
10041
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10042 3868 sprite::drawshadow(dest, translucent);
10043 3868 xofs+=8;
10044 3868 yofs=tempy;
10045 3868 }
10046 4440 }
10047
10048 4440 void eBoulder::draw(BITMAP *dest)
10049 {
10050
4/6
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
✓ Branch 2 taken 572 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 572 times.
4440 if(clk2>=0 || fallclk||drownclk)
10051 {
10052 3868 int32_t tempdir=dir;
10053 3868 dir=dummy_int[2];
10054 3868 update_enemy_frame();
10055 3868 dir=tempdir;
10056 3868 xofs-=8;
10057 3868 yofs-=8;
10058 3868 drawblock(dest,15);
10059 3868 xofs+=8;
10060 3868 yofs+=8;
10061 // enemy::draw(dest);
10062 3868 }
10063 4440 }
10064
10065 30 void eBoulder::init_size_flags()
10066 {
10067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ((d->SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
10068 30 else hxofs = -10;
10069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ((d->SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
10070 30 else hyofs = -10;
10071
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
10072 30 else hit_width = 36;
10073
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
10074 30 else hit_height = 36;
10075
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
10076 30 else hzsz = 16; //can't be jumped
10077
10078
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if (((d->SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10079
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if (((d->SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
10080
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
10081
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
10082
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
10083 {
10084 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10085 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
10086 }
10087
10088
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
10089 30 }
10090
10091 int32_t eBoulder::takehit(weapon*,weapon*)
10092 {
10093 return 0;
10094 }
10095
10096 4429 eProjectile::eProjectile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk),
10097
2/2
✓ Branch 0 taken 531 times.
✓ Branch 1 taken 3898 times.
4429 minRange(get_qr(qr_BROKENSTATUES) ? 0 : Clk)
10098 4429 {
10099 /* fixing
10100 hp=1;
10101 */
10102 4429 mainguy=false;
10103
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 4422 times.
4429 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10104 4429 hclk=clk; // the "no fire" range
10105 4429 clk=0;
10106 4429 clk3=96;
10107 4429 timer=0;
10108
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 4415 times.
4429 if(o_tile==0)
10109 {
10110 4415 superman=1;
10111 4415 hxofs=1000;
10112 4415 }
10113
1/4
✓ Branch 0 taken 4429 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4429 if (SIZEflags != 0) init_size_flags();;
10114 4429 }
10115
10116 2504746 bool eProjectile::animate(int32_t index)
10117 {
10118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2504746 times.
2504746 if(switch_hooked) return enemy::animate(index);
10119
2/4
✓ Branch 0 taken 2504746 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2504746 times.
2504746 if(fallclk||drownclk) return enemy::animate(index);
10120
2/2
✓ Branch 0 taken 2492420 times.
✓ Branch 1 taken 12326 times.
2504746 if(clk==0)
10121 {
10122 12326 removearmos(x,y);
10123 12326 }
10124
10125 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10126 2504746 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10127
10128
4/4
✓ Branch 0 taken 835608 times.
✓ Branch 1 taken 1669138 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 403631 times.
2504746 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10129 {
10130 403631 dir=down;
10131 403631 }
10132
4/4
✓ Branch 0 taken 1348897 times.
✓ Branch 1 taken 752218 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 916920 times.
2101115 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10133 {
10134 916920 dir=right;
10135 916920 }
10136
4/4
✓ Branch 0 taken 790877 times.
✓ Branch 1 taken 393318 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 358900 times.
1184195 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
10137 {
10138 358900 dir=up;
10139 358900 }
10140 else
10141 {
10142 825295 dir=left;
10143 }
10144
10145
3/4
✓ Branch 0 taken 2504746 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1306267 times.
✓ Branch 3 taken 1198479 times.
2504746 if(!stunclk && ++clk3>80)
10146 {
10147
2/2
✓ Branch 0 taken 1046 times.
✓ Branch 1 taken 1197433 times.
1198479 if(dmisc1==9) // Breath type
10148 {
10149
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 563 times.
1046 if(timer==0)
10150 {
10151 563 unsigned r=zc_oldrand();
10152
10153
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 557 times.
563 if(!(r&63))
10154 {
10155 6 timer=zc_oldrand()%50+50;
10156 6 }
10157 563 }
10158
10159
2/2
✓ Branch 0 taken 557 times.
✓ Branch 1 taken 489 times.
1046 if(timer>0)
10160 {
10161
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 119 times.
489 if(timer%4==0)
10162 {
10163 119 FireBreath(false);
10164 119 }
10165
10166
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 6 times.
489 if(--timer==0)
10167 {
10168 6 clk3=0;
10169 6 }
10170 489 }
10171 1046 }
10172
10173 else // Not breath type
10174 {
10175 1197433 unsigned r=zc_oldrand();
10176
10177
4/4
✓ Branch 0 taken 18808 times.
✓ Branch 1 taken 1178625 times.
✓ Branch 2 taken 1266 times.
✓ Branch 3 taken 17542 times.
1197433 if(!(r&63) && !HeroInRange(minRange))
10178 {
10179 17542 FireWeapon();
10180
10181
4/4
✓ Branch 0 taken 15040 times.
✓ Branch 1 taken 2502 times.
✓ Branch 2 taken 186 times.
✓ Branch 3 taken 66 times.
17794 if(get_qr(qr_BROKENSTATUES)==0 &&
10182
3/4
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 14788 times.
✓ Branch 2 taken 252 times.
✗ Branch 3 not taken.
15040 ((wpn==ewFireball || wpn==ewFireball2) || dmisc1==e1tNORMAL))
10183 {
10184
2/2
✓ Branch 0 taken 13945 times.
✓ Branch 1 taken 909 times.
14854 if(!((r>>7)&15))
10185 {
10186 909 x-=4;
10187 909 FireWeapon();
10188 909 x+=4;
10189 909 }
10190 14854 }
10191
10192 17542 clk3=0;
10193 17542 }
10194 }
10195 1198479 }
10196
10197 2504746 return enemy::animate(index);
10198 2504746 }
10199
10200 2520335 void eProjectile::draw(BITMAP *dest)
10201 {
10202 2520335 update_enemy_frame();
10203 2520335 enemy::draw(dest);
10204 2520335 }
10205
10206 533 eTrigger::eTrigger(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10207 533 {
10208 533 hxofs=1000;
10209 533 }
10210
10211 249811 void eTrigger::draw(BITMAP *dest)
10212 {
10213 249811 update_enemy_frame();
10214 249811 enemy::draw(dest);
10215 249811 }
10216
10217 void eTrigger::death_sfx()
10218 {
10219 //silent death
10220 }
10221
10222 5 eNPC::eNPC(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10223 5 {
10224 5 o_tile+=wpnsbuf[iwNPCs].tile;
10225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10226 5 SIZEflags = d->SIZEflags;
10227
1/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if (SIZEflags != 0) init_size_flags();;
10228 5 }
10229
10230 75 bool eNPC::animate(int32_t index)
10231 {
10232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(switch_hooked) return enemy::animate(index);
10233
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 5 times.
75 if(dying)
10234 70 return Dead(index);
10235
10236
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(clk==0)
10237 {
10238 removearmos(x,y);
10239 }
10240
10241
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 switch(dmisc2)
10242 {
10243 case 0:
10244 {
10245 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10246 5 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10247
10248
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10249 {
10250 dir=down;
10251 }
10252
10253
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10254 {
10255 5 dir=right;
10256 5 }
10257 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/8)))
10258 {
10259 dir=up;
10260 }
10261 else
10262 {
10263 dir=left;
10264 }
10265 }
10266 5 break;
10267
10268 case 1:
10269 halting_walk(rate, homing, 0, hrate, 48);
10270
10271 if(clk2==1 && (misc < dmisc1) && !(zc_oldrand()&15))
10272 {
10273 newdir(rate, homing, 0);
10274 clk2=48;
10275 ++misc;
10276 }
10277
10278 if(clk2==0)
10279 misc=0;
10280
10281 break;
10282 }
10283
10284 5 return enemy::animate(index);
10285 75 }
10286
10287 75 void eNPC::draw(BITMAP *dest)
10288 {
10289 75 update_enemy_frame();
10290 75 enemy::draw(dest);
10291 75 }
10292
10293 int32_t eNPC::takehit(weapon*,weapon*)
10294 {
10295 return 0;
10296 }
10297
10298 94 eSpinTile::eSpinTile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10299 94 {
10300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if(clk>0) // clk>0 when created by a Spinning Tile combo
10301 {
10302 94 o_tile=clk;
10303 94 cs=id>>12;
10304 94 }
10305
10306 94 id=id&0xFFF;
10307 94 clk=0;
10308
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 step=0;
10309 94 mainguy=false;
10310 94 SIZEflags = d->SIZEflags;
10311
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if (SIZEflags != 0) init_size_flags();;
10312 94 }
10313
10314 81 void eSpinTile::facehero()
10315 {
10316
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 80 times.
81 if(Hero.x-x==0)
10317 {
10318
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (Hero.y + 8 < y)
10319 1 dir = up;
10320 else
10321 dir = down;
10322 1 }
10323 else
10324 {
10325 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10326 80 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10327
10328
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
80 if((ddir <= -5.0*PI/8.0) && (ddir > -7.0*PI/8.0))
10329 {
10330 12 dir=l_down;
10331 12 }
10332
4/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 1 times.
68 else if ((ddir <= -3.0*PI / 8.0) && (ddir > -5.0*PI / 8.0))
10333 {
10334 1 dir=down;
10335 1 }
10336
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
67 else if ((ddir <= -1.0*PI / 8.0) && (ddir > -3.0*PI / 8.0))
10337 {
10338 12 dir=r_down;
10339 12 }
10340
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 6 times.
55 else if ((ddir <= 1.0*PI / 8.0) && (ddir > -1.0*PI / 8.0))
10341 {
10342 6 dir=right;
10343 6 }
10344
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 17 times.
49 else if ((ddir <= 3.0*PI / 8.0) && (ddir > 1.0*PI / 8.0))
10345 {
10346 17 dir=r_up;
10347 17 }
10348
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 8 times.
32 else if ((ddir <= 5.0*PI / 8.0) && (ddir > 3.0*PI / 8.0))
10349 {
10350 8 dir=up;
10351 8 }
10352
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 10 times.
24 else if ((ddir <= 7.0*PI / 8.0) && (ddir > 5.0*PI / 8.0))
10353 {
10354 6 dir=l_up;
10355 6 }
10356 else
10357 {
10358 18 dir=left;
10359 }
10360 }
10361 81 }
10362
10363
10364 15539 bool eSpinTile::animate(int32_t index)
10365 {
10366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15539 times.
15539 if(switch_hooked) return enemy::animate(index);
10367
2/4
✓ Branch 0 taken 15539 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15539 times.
15539 if(fallclk||drownclk) return enemy::animate(index);
10368
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 14387 times.
15539 if(dying)
10369 {
10370 1152 return Dead(index);
10371 }
10372
10373
2/2
✓ Branch 0 taken 13146 times.
✓ Branch 1 taken 1241 times.
14387 if(clk==0)
10374 {
10375 1241 removearmos(x,y);
10376 1241 }
10377
10378 14387 ++misc;
10379
10380
2/2
✓ Branch 0 taken 14306 times.
✓ Branch 1 taken 81 times.
14387 if(misc==96)
10381 {
10382 81 facehero();
10383 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10384 81 double ddir=atan2_MSVC2022_FIX(double((Hero.y)-y),double(Hero.x-x));
10385 81 angular=true;
10386 81 angle=ddir;
10387 81 step=zslongToFix(dstep*100);
10388 81 }
10389
10390
8/8
✓ Branch 0 taken 14374 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 14359 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 14353 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 14335 times.
14387 if(y>186 || y<=-16 || x>272 || x<=-16)
10391 52 kickbucket();
10392
10393 14387 sprite::move(step);
10394 14387 return enemy::animate(index);
10395 15539 }
10396
10397 15457 void eSpinTile::draw(BITMAP *dest)
10398 {
10399 15457 update_enemy_frame();
10400 15457 y-=(misc>>4);
10401 15457 yofs+=2;
10402 15457 enemy::draw(dest);
10403 15457 yofs-=2;
10404 15457 y+=(misc>>4);
10405 15457 }
10406
10407 15457 void eSpinTile::drawshadow(BITMAP *dest, bool translucent)
10408 {
10409 15457 flip = 0;
10410 15457 shadowtile = wpnsbuf[spr_shadow].tile+(clk%4);
10411 15457 yofs+=4;
10412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15457 times.
15457 if(!shadow_overpit(this))
10413 15457 enemy::drawshadow(dest, translucent);
10414 15457 yofs-=4;
10415 15457 }
10416
10417 2797 eZora::eZora(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
10418 2797 {
10419 //these are here to bypass compiler warnings about unused arguments
10420 2797 Clk=Clk;
10421 2797 mainguy=false;
10422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2797 times.
2797 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10423
1/4
✓ Branch 0 taken 2797 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2797 if (SIZEflags != 0) init_size_flags();;
10424 2797 }
10425
10426 628398 void eZora::facehero()
10427 {
10428
2/2
✓ Branch 0 taken 10785 times.
✓ Branch 1 taken 617613 times.
628398 if(Hero.x-x==0)
10429 {
10430 10785 dir=(Hero.y+8<y)?up:down;
10431 10785 }
10432 else
10433 {
10434 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10435 617613 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10436
10437
4/4
✓ Branch 0 taken 125430 times.
✓ Branch 1 taken 492183 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 78554 times.
617613 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
10438 {
10439 78554 dir=l_down;
10440 78554 }
10441
4/4
✓ Branch 0 taken 91951 times.
✓ Branch 1 taken 447108 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 45075 times.
539059 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
10442 {
10443 45075 dir=down;
10444 45075 }
10445
4/4
✓ Branch 0 taken 121090 times.
✓ Branch 1 taken 372894 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 74214 times.
493984 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
10446 {
10447 74214 dir=r_down;
10448 74214 }
10449
4/4
✓ Branch 0 taken 162238 times.
✓ Branch 1 taken 257532 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 115362 times.
419770 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
10450 {
10451 115362 dir=right;
10452 115362 }
10453
4/4
✓ Branch 0 taken 127279 times.
✓ Branch 1 taken 177129 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 80403 times.
304408 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
10454 {
10455 80403 dir=r_up;
10456 80403 }
10457
4/4
✓ Branch 0 taken 88819 times.
✓ Branch 1 taken 135186 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 41943 times.
224005 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
10458 {
10459 41943 dir=up;
10460 41943 }
10461
4/4
✓ Branch 0 taken 121548 times.
✓ Branch 1 taken 60514 times.
✓ Branch 2 taken 74672 times.
✓ Branch 3 taken 46876 times.
182062 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
10462 {
10463 74672 dir=l_up;
10464 74672 }
10465 else
10466 {
10467 107390 dir=left;
10468 }
10469 }
10470 628398 }
10471
10472 857137 bool eZora::animate(int32_t index)
10473 {
10474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 857137 times.
857137 if(switch_hooked) return enemy::animate(index);
10475
2/2
✓ Branch 0 taken 2854 times.
✓ Branch 1 taken 854283 times.
857137 if(dying)
10476 2854 return Dead(index);
10477
10478
2/2
✓ Branch 0 taken 848537 times.
✓ Branch 1 taken 5746 times.
854283 if(clk==0)
10479 {
10480 5746 removearmos(x,y);
10481 5746 }
10482
10483
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 854248 times.
854283 if(watch)
10484 {
10485 35 clock_zoras.push_back({screen_spawned, id});
10486 35 return true;
10487 }
10488
10489
2/2
✓ Branch 0 taken 225850 times.
✓ Branch 1 taken 628398 times.
854248 if(get_qr(qr_NEWENEMYTILES))
10490 {
10491 628398 facehero();
10492 628398 }
10493
10494
6/6
✓ Branch 0 taken 5232 times.
✓ Branch 1 taken 4993 times.
✓ Branch 2 taken 4190 times.
✓ Branch 3 taken 830374 times.
✓ Branch 4 taken 6482 times.
✓ Branch 5 taken 2977 times.
854248 switch(clk)
10495 {
10496 case 0: // reposition him
10497 {
10498 6482 int32_t t=0;
10499 6482 int32_t pos2=zc_oldrand()%160 + 16;
10500 6482 bool placed=false;
10501
10502
4/4
✓ Branch 0 taken 6417 times.
✓ Branch 1 taken 38529 times.
✓ Branch 2 taken 26366 times.
✓ Branch 3 taken 5746 times.
44946 while(!placed && t<160)
10503 {
10504 26366 rpos_t rpos = POS_TO_RPOS(pos2, screen_spawned);
10505 90460 auto [sx, sy] = COMBOXY_REGION(rpos);
10506 26366 mapscr* s = get_scr(screen_spawned);
10507
10508 79098 int32_t watertype = iswaterex_z3(s->data[pos2], -1, sx, sy, false, true, true, (bool)(editorflags & ENEMY_FLAG7));
10509
5/6
✓ Branch 0 taken 6604 times.
✓ Branch 1 taken 19762 times.
✓ Branch 2 taken 6604 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 400 times.
✓ Branch 5 taken 5681 times.
32447 if(watertype && ((editorflags & ENEMY_FLAG6) ||
10510
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 6572 times.
6604 ((combobuf[watertype].usrflags&cflag1) && (editorflags & ENEMY_FLAG5))
10511
3/4
✓ Branch 0 taken 6572 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6081 times.
✓ Branch 3 taken 6049 times.
6604 || (!(combobuf[watertype].usrflags&cflag1) && !(editorflags & ENEMY_FLAG5))) && (pos2&15)>0 && (pos2&15)<15)
10512 {
10513 5681 x=sx;
10514 5681 y=sy;
10515
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 5341 times.
5681 if (!(editorflags & ENEMY_FLAG8)) hp=guysbuf[id&0xFFF].hp; // refill life each time, unless the flag is checked.
10516 5681 hxofs=1000; // avoid hit detection
10517 5681 stunclk=0;
10518 5681 placed=true;
10519 5681 }
10520
10521 38464 pos2+=19;
10522
10523
2/2
✓ Branch 0 taken 33901 times.
✓ Branch 1 taken 4563 times.
38464 if(pos2>=176)
10524 4563 pos2-=160;
10525
10526 38464 ++t;
10527 }
10528
10529
3/4
✓ Branch 0 taken 5681 times.
✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5681 times.
5746 if(!placed || whistleclk>=88) // can't place him, he's gone
10530 65 return true;
10531
10532 }
10533 5681 break;
10534
10535 case 35:
10536
2/2
✓ Branch 0 taken 3871 times.
✓ Branch 1 taken 1361 times.
5232 if(!get_qr(qr_NEWENEMYTILES))
10537 {
10538 1361 dir=(Hero.y+8<y)?up:down;
10539 1361 }
10540
10541 5232 hxofs=0;
10542 5232 break;
10543
10544 case 35+19:
10545 4993 addEwpn(x,y,z,wpn,2,wdp,dir,getUID(), 0, fakez);
10546 4993 sfx(wpnsfx(wpn),pan(x));
10547 4993 break;
10548
10549 case 35+66:
10550 4190 hxofs=1000;
10551 4190 break;
10552
10553 case 198:
10554 2977 clk=-1;
10555 2977 break;
10556 }
10557
10558 853447 return enemy::animate(index);
10559 856401 }
10560
10561 867086 void eZora::draw(BITMAP *dest)
10562 {
10563
2/2
✓ Branch 0 taken 20009 times.
✓ Branch 1 taken 847077 times.
867086 if (isSubmerged())
10564 20009 return;
10565
10566 847077 update_enemy_frame();
10567 847077 enemy::draw(dest);
10568 867086 }
10569
10570 867318 bool eZora::isSubmerged() const
10571 {
10572 867318 return clk < 3;
10573 }
10574
10575
3/6
✓ Branch 0 taken 50257 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50257 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50257 times.
✗ Branch 5 not taken.
100514 eStalfos::eStalfos(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10576 50257 {
10577 50257 multishot= timer = fired = dashing = 0;
10578 50257 hashero = false;
10579 50257 dummy_bool[0]=false;
10580
4/8
✓ Branch 0 taken 50257 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50257 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50257 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 50257 times.
✗ Branch 7 not taken.
50257 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
10581
5/6
✓ Branch 0 taken 1002 times.
✓ Branch 1 taken 49255 times.
✓ Branch 2 taken 1002 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 519 times.
✓ Branch 5 taken 483 times.
50257 if(dmisc9==e9tARMOS && zc_oldrand()&1)
10582 {
10583
2/4
✓ Branch 0 taken 519 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 519 times.
✗ Branch 3 not taken.
519 step=zslongToFix(dmisc10*100);
10584
10585
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 501 times.
519 if(anim==aARMOS4) o_tile+=20;
10586 519 }
10587
10588
3/4
✓ Branch 0 taken 50257 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1002 times.
✓ Branch 3 taken 49255 times.
50257 if(flags & guy_fade_flicker)
10589 {
10590 1002 clk=0;
10591 1002 superman = 1;
10592 1002 fading=fade_flicker;
10593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1002 times.
1002 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10594 1002 dir=down;
10595
10596
4/6
✓ Branch 0 taken 1002 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1002 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 561 times.
1002 if(!canmove(down,(zfix)8,spw_none,false))
10597
3/6
✓ Branch 0 taken 441 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 441 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 441 times.
✗ Branch 5 not taken.
441 clk3=int32_t(13.0/step);
10598 1002 }
10599
3/4
✓ Branch 0 taken 49255 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49122 times.
✓ Branch 3 taken 133 times.
49255 else if(flags & guy_fade_instant)
10600 {
10601 133 clk=0;
10602 133 }
10603
10604
1/2
✓ Branch 0 taken 50257 times.
✗ Branch 1 not taken.
50257 shadowdistance = 0;
10605 50257 clk4 = clk5 = 0;
10606 //nets+2380;
10607
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 50255 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
50257 if (SIZEflags != 0) init_size_flags();;
10608 50257 }
10609
10610 15823224 bool eStalfos::animate(int32_t index)
10611 {
10612
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 15822968 times.
15823224 if(switch_hooked) return enemy::animate(index);
10613
3/4
✓ Branch 0 taken 15822542 times.
✓ Branch 1 taken 426 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15822542 times.
15822968 if(fallclk||drownclk)
10614 {
10615 426 return enemy::animate(index);
10616 }
10617
2/2
✓ Branch 0 taken 353022 times.
✓ Branch 1 taken 15469520 times.
15822542 if(dying)
10618 {
10619
2/2
✓ Branch 0 taken 352974 times.
✓ Branch 1 taken 48 times.
353022 if(hashero)
10620 {
10621 48 Hero.setEaten(0);
10622 48 hashero=false;
10623 48 }
10624
10625
10/14
✓ Branch 0 taken 36032 times.
✓ Branch 1 taken 316990 times.
✓ Branch 2 taken 3685 times.
✓ Branch 3 taken 32347 times.
✓ Branch 4 taken 187 times.
✓ Branch 5 taken 3498 times.
✓ Branch 6 taken 187 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 187 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 187 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 187 times.
353022 if(dmisc9==e9tROPE && dmisc2==e2tBOMBCHU && !fired && (hp<=0 && !immortal) && hp>-1000 && wpn>wEnemyWeapons)
10626 {
10627 187 hp=-1000;
10628
5/10
✓ Branch 0 taken 187 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 187 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 187 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 187 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 187 times.
✗ Branch 9 not taken.
187 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID(),false);
10629 187 Ewpns.add(ew);
10630 187 ew->fakez = fakez;
10631
10632
3/4
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
187 if(wpn==ewSBomb || wpn==ewBomb)
10633 {
10634 187 ew->step=0;
10635 187 ew->id=wpn;
10636 187 ew->misc=50;
10637 187 ew->clk=48;
10638 187 }
10639
10640 187 fired=true;
10641 187 }
10642
6/6
✓ Branch 0 taken 156368 times.
✓ Branch 1 taken 196467 times.
✓ Branch 2 taken 130316 times.
✓ Branch 3 taken 26052 times.
✓ Branch 4 taken 130298 times.
✓ Branch 5 taken 18 times.
352835 else if(wpn && wpn!=ewBrang && dmisc2==e2tFIREOCTO) // Fire Octo
10643 {
10644
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1 times.
18 if(!dummy_bool[0])
10645 {
10646 1 int32_t wpn2 = wpn+dmisc3;
10647
10648
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(wpn2 <= wEnemyWeapons || wpn2 >= wMax)
10649 {
10650 wpn2=wpn;
10651 }
10652
10653 1 dummy_bool[0]=true;
10654 1 addEwpn(x,y,z,wpn2,0,dmisc4,up, getUID(), 0, fakez);
10655 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10656 1 addEwpn(x,y,z,wpn2,0,dmisc4,down, getUID(), 0, fakez);
10657 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10658 1 addEwpn(x,y,z,wpn2,0,dmisc4,left, getUID(), 0, fakez);
10659 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10660 1 addEwpn(x,y,z,wpn2,0,dmisc4,right, getUID(), 0, fakez);
10661 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10662 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_up, getUID(), 0, fakez);
10663 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10664 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_up, getUID(), 0, fakez);
10665 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10666 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_down, getUID(), 0, fakez);
10667 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10668 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_down, getUID(), 0, fakez);
10669 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10670 1 sfx(wpnsfx(wpn2),pan(x));
10671 1 }
10672 18 }
10673
10674 353022 KillWeapon();
10675 353022 return Dead(index);
10676 }
10677 //vire split
10678 //2.10 checked !fslide(), but nothing uses that now anyway. -Z
10679 //Perhaps the problem occurs when vires die because they have < 0 HP, in this check?
10680
13/14
✓ Branch 0 taken 21143 times.
✓ Branch 1 taken 15448377 times.
✓ Branch 2 taken 21143 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 351 times.
✓ Branch 5 taken 20792 times.
✓ Branch 6 taken 1192696 times.
✓ Branch 7 taken 14276473 times.
✓ Branch 8 taken 1191149 times.
✓ Branch 9 taken 1547 times.
✓ Branch 10 taken 6686 times.
✓ Branch 11 taken 1184463 times.
✓ Branch 12 taken 1326 times.
✓ Branch 13 taken 5360 times.
15469520 else if(((hp<=0 && !immortal) && dmisc2==e2tSPLIT) || (dmisc2==e2tSPLITHIT && hp>0 && hp<guysbuf[id&0xFFF].hp && !slide() && (sclk&255)<=1)) //Split into enemies
10681 {
10682 1677 stop_bgsfx(index);
10683 1677 int32_t kids = guys.Count();
10684 1677 int32_t id2=dmisc3;
10685
2/2
✓ Branch 0 taken 3307 times.
✓ Branch 1 taken 1677 times.
4984 for(int32_t i=0; i < dmisc4; i++)
10686 {
10687
4/6
✓ Branch 0 taken 1272 times.
✓ Branch 1 taken 2035 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2035 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3307 times.
3307 if(addenemy(screen_spawned,x,y,id2+(guysbuf[id2].type==eeKEESE ? 0 : ((editorflags & ENEMY_FLAG5) ? 0 : (i<<12))),-21-(i%4)))
10688 3307 ((enemy*)guys.spr(kids+i))->count_enemy = false;
10689 3307 }
10690
10691
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1676 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1677 if (itemguy && guys.Count()) // Hand down the carried item
10692 {
10693 1 int guycarryingitem = guys.Count()-1;
10694 1 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
10695 1 itemguy = false;
10696 1 }
10697
10698
2/2
✓ Branch 0 taken 1660 times.
✓ Branch 1 taken 17 times.
1677 if(hashero)
10699 {
10700 17 Hero.setEaten(0);
10701 17 hashero=false;
10702 17 }
10703
10704
4/4
✓ Branch 0 taken 1649 times.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 1326 times.
✓ Branch 3 taken 323 times.
1677 if(deadsfx > 0 && dmisc2==e2tSPLIT)
10705 323 sfx(deadsfx,pan(x));
10706
10707 1677 return true;
10708 }
10709
10710
2/2
✓ Branch 0 taken 71161 times.
✓ Branch 1 taken 15396682 times.
15467843 if(fading)
10711 {
10712
2/2
✓ Branch 0 taken 1228 times.
✓ Branch 1 taken 69933 times.
71161 if(++clk4 > 60)
10713 {
10714 1228 clk4=0;
10715 1228 superman=0;
10716 1228 fading=0;
10717
10718
4/6
✓ Branch 0 taken 967 times.
✓ Branch 1 taken 261 times.
✓ Branch 2 taken 967 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 967 times.
1228 if(flags&guy_armos && z==0 && fakez == 0)
10719 {
10720 //if a custom size (not 16px by 16px)
10721
10722 //if a custom size (not 16px by 16px)
10723
3/4
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 791 times.
✓ Branch 2 taken 176 times.
✗ Branch 3 not taken.
967 if (activated_handle && !activated_handle->is_rpos())
10724 removearmos(x,y);
10725 else
10726 {
10727
4/8
✓ Branch 0 taken 967 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 967 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 967 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 967 times.
967 if (txsz > 1 || tysz > 1 || (SIZEflags&OVERRIDE_HIT_WIDTH) || (SIZEflags&OVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
10728 {
10729 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
10730 for(int32_t dx = 0; dx < tysz; dx ++)
10731 {
10732 for(int32_t dy = 0; dy < tysz; dy++)
10733 {
10734 removearmos((int32_t)x+(dx*16),(int32_t)y+(dy*16)+1);
10735 did_armos = false;
10736 }
10737 removearmos((int32_t)x+(dx*16), (int32_t)y+((tysz-1)*16)+1);
10738 did_armos = false;
10739 }
10740 for(int32_t dy = 0; dy < tysz; dy ++)
10741 {
10742 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+(dy*16)+1);
10743 did_armos = false;
10744 }
10745 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+((tysz-1)*16)+1);
10746 }
10747 967 else removearmos(x,y);
10748 }
10749
10750 967 }
10751
10752 1228 clk2=0;
10753
10754 1228 newdir();
10755 1228 }
10756 69933 else return enemy::animate(index);
10757 1228 }
10758
6/8
✓ Branch 0 taken 148409 times.
✓ Branch 1 taken 15248273 times.
✓ Branch 2 taken 148409 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 148409 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 138854 times.
✓ Branch 7 taken 9555 times.
15396682 else if(flags&guy_armos && z==0 && fakez == 0 && clk==0)
10759 9555 removearmos(x,y);
10760
10761
10762
2/2
✓ Branch 0 taken 7207 times.
✓ Branch 1 taken 15390703 times.
15397910 if(hashero)
10763 {
10764 7207 Hero.setX(x);
10765 7207 Hero.setY(y);
10766 7207 ++clk2;
10767
10768
4/4
✓ Branch 0 taken 5694 times.
✓ Branch 1 taken 1513 times.
✓ Branch 2 taken 6308 times.
✓ Branch 3 taken 899 times.
7207 if(clk2==(dmisc8==0 ? 95 : dmisc8))
10769 {
10770
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 877 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
899 switch(dmisc7)
10771 {
10772 case e7tEATITEMS:
10773 {
10774
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i=0; i<MAXITEMS; i++)
10775 {
10776
2/2
✓ Branch 0 taken 5610 times.
✓ Branch 1 taken 22 times.
5632 if(itemsbuf[i].flags&item_edible)
10777 22 game->set_item(i, false);
10778 5632 }
10779
10780 22 break;
10781 }
10782
10783 case e7tEATMAGIC:
10784 game->change_dmagic(-1*game->get_magicdrainrate());
10785 break;
10786
10787 case e7tEATRUPEES:
10788 game->change_drupy(-1);
10789 break;
10790 }
10791
10792 899 clk2=0;
10793 899 }
10794
10795
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 6661 times.
7207 if((clk&0x18)==8) // stop its animation on the middle frame
10796 6661 --clk;
10797 7207 }
10798
4/4
✓ Branch 0 taken 1048873 times.
✓ Branch 1 taken 14341830 times.
✓ Branch 2 taken 616037 times.
✓ Branch 3 taken 432836 times.
15390703 else if(!(wpn==ewBrang && WeaponOut())) //WeaponOut uses misc
10799 {
10800 // Movement engine
10801
6/6
✓ Branch 0 taken 839470 times.
✓ Branch 1 taken 14118397 times.
✓ Branch 2 taken 3294 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 14114936 times.
✓ Branch 5 taken 59 times.
14957867 if(clk>=0) switch(id>>12)
10802 {
10803 case 0: // Normal movement
10804
10805 /*
10806 if((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && !slide()) //Leever
10807 {
10808 // Overloading clk4 (Tribble clock) here...
10809 step=17/100.0;
10810 if(clk4<32) misc=1;
10811 else if(clk4<48) misc=2;
10812 else if(clk4<300) { misc=3; step = dstep/100.0; }
10813 else if(clk4<316) misc=2;
10814 else if(clk4<412) misc=1;
10815 else if(clk4<540) { misc=0; step=0; }
10816 else clk4=0;
10817 if(clk4==48) clk=0;
10818 hxofs=(misc>=2)?0:1000;
10819 if (dmisc9==e9tLEEVER)
10820 variable_walk(rate, homing, 0);
10821 else
10822 variable_walk_8(rate, homing, 4, 0);
10823 break;
10824 }
10825 */
10826
4/4
✓ Branch 0 taken 13735902 times.
✓ Branch 1 taken 379034 times.
✓ Branch 2 taken 417076 times.
✓ Branch 3 taken 13318826 times.
14114936 if(dmisc9==e9tVIRE || dmisc9==e9tPOLSVOICE) //Vire
10827 {
10828 796110 vire_hop();
10829 796110 break;
10830 }
10831
2/2
✓ Branch 0 taken 984687 times.
✓ Branch 1 taken 12334139 times.
13318826 else if(dmisc9==e9tROPE) //Rope charge
10832 {
10833
9/10
✓ Branch 0 taken 967265 times.
✓ Branch 1 taken 17422 times.
✓ Branch 2 taken 138779 times.
✓ Branch 3 taken 828486 times.
✓ Branch 4 taken 126694 times.
✓ Branch 5 taken 12085 times.
✓ Branch 6 taken 125869 times.
✓ Branch 7 taken 825 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 125869 times.
984687 if(!fired && dashing && !stunclk && !watch && !frozenclock)
10834 {
10835
5/6
✓ Branch 0 taken 9076 times.
✓ Branch 1 taken 116793 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 9029 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 47 times.
125869 if(dmisc2==e2tBOMBCHU && HeroInRange(16) && wpn+dmisc3 > wEnemyWeapons) //Bombchu
10836 {
10837
10838
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 33 times.
47 if ( get_qr(qr_BOMBCHUSUPERBOMB) )
10839 {
10840 14 hp=-1000;
10841
10842
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
10843 {
10844
5/10
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14 times.
✗ Branch 9 not taken.
14 weapon *ew=new weapon(x,y,z, wpn+dmisc3, 0, dmisc4, dir,-1,getUID());
10845 14 Ewpns.add(ew);
10846 14 ew->fakez = fakez;
10847
10848
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(wpn==ewSBomb || wpn==ewBomb)
10849 {
10850 14 ew->step=0;
10851 14 ew->id=wpn+dmisc3;
10852 14 ew->misc=50;
10853 14 ew->clk=48;
10854 14 }
10855
10856 14 fired=true;
10857 14 }
10858 else
10859 {
10860 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID());
10861 Ewpns.add(ew);
10862 ew->fakez = fakez;
10863
10864 if(wpn==ewSBomb || wpn==ewBomb)
10865 {
10866 ew->step=0;
10867 ew->id=wpn;
10868 ew->misc=50;
10869 ew->clk=48;
10870 }
10871
10872 fired=true;
10873 }
10874 14 }
10875
10876 else
10877 {
10878 33 hp=-1000;
10879
10880 int32_t wpn2;
10881
2/4
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
33 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
10882 33 wpn2=wpn;
10883 else
10884 wpn2=wpn;
10885
10886
5/10
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 33 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 33 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 33 times.
✗ Branch 9 not taken.
33 weapon *ew=new weapon(x,y,z, wpn2, 0, dmisc4, dir,-1,getUID());
10887 33 Ewpns.add(ew);
10888 33 ew->fakez = fakez;
10889
10890
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
33 if(wpn2==ewSBomb || wpn2==ewBomb)
10891 {
10892 33 ew->step=0;
10893 33 ew->id=wpn2;
10894 33 ew->misc=50;
10895 33 ew->clk=48;
10896 33 }
10897
10898 33 fired=true;
10899 }
10900 47 }
10901 125869 }
10902
10903 984687 charge_attack();
10904 984687 break;
10905 }
10906 /*
10907 * Boomerang-throwers have a halt count of 1
10908 * Zols have a halt count of (zc_oldrand()&7)<<4
10909 * Gels have a halt count of ((zc_oldrand()&7)<<3)+2
10910 * Everything else has 48
10911 */
10912 else
10913 {
10914
2/2
✓ Branch 0 taken 568419 times.
✓ Branch 1 taken 11765720 times.
12334139 if(wpn==ewBrang) // Goriya
10915 {
10916 568419 halting_walk(rate,homing,0,hrate, 1);
10917 568419 }
10918
4/4
✓ Branch 0 taken 11616344 times.
✓ Branch 1 taken 149376 times.
✓ Branch 2 taken 4552225 times.
✓ Branch 3 taken 7064119 times.
11765720 else if(dmisc9==e9tNORMAL && wpn==0)
10919 {
10920
2/2
✓ Branch 0 taken 717973 times.
✓ Branch 1 taken 6346146 times.
7064119 if(dmisc2==e2tSPLITHIT) // Zol
10921 {
10922 717973 halting_walk(rate,homing,0,hrate,(zc_oldrand()&7)<<4);
10923 717973 }
10924
4/4
✓ Branch 0 taken 1754155 times.
✓ Branch 1 taken 4591991 times.
✓ Branch 2 taken 1538264 times.
✓ Branch 3 taken 215891 times.
6346146 else if(frate<=8 && starting_hp==1) // Gel
10925 {
10926 215891 halting_walk(rate,homing,0,hrate,((zc_oldrand()&7)<<3)+2);
10927 215891 }
10928 else // Other
10929 {
10930 6130255 halting_walk(rate,homing,0,hrate, 48);
10931 }
10932 7064119 }
10933 else // Other
10934 {
10935 4701601 halting_walk(rate,homing,0,hrate, 48);
10936 }
10937 }
10938
10939 //if not in midair, and Hero's swinging sword is nearby, jump.
10940 /*if (dmisc9==e9tZ3STALFOS && z==0 && (!(isSideViewGravity()) || !_walkflag(x,y+16,0))
10941 && Hero.getAttackClk()==5 && Hero.getAttack()==wSword && distance(x,y,Hero.getX(),Hero.getY())<32)
10942 {
10943 facehero(false);
10944 sclk=16+((dir^1)<<8);
10945 fall=-FEATHERJUMP;
10946 sfx(WAV_ZN1JUMP,pan(x));
10947 }*/
10948 12334139 break;
10949
10950 // Following cases are for just after creation-by-splitting.
10951 case 1:
10952
2/2
✓ Branch 0 taken 2473 times.
✓ Branch 1 taken 821 times.
3294 if(misc==1)
10953 {
10954 821 dir=up;
10955 821 step=8;
10956 821 }
10957
10958
2/2
✓ Branch 0 taken 790 times.
✓ Branch 1 taken 2504 times.
3294 if(misc<=2)
10959 {
10960 2504 move(step);
10961
10962
2/2
✓ Branch 0 taken 1992 times.
✓ Branch 1 taken 512 times.
2504 if(!canmove(dir,(zfix)0,0,false))
10963 512 dir=down;
10964 2504 }
10965
10966
2/2
✓ Branch 0 taken 2504 times.
✓ Branch 1 taken 790 times.
3294 if(misc==3)
10967 {
10968
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 503 times.
790 if(canmove(right,(zfix)16,0,false))
10969 503 x+=16;
10970 790 }
10971
10972 3294 ++misc;
10973 3294 break;
10974
10975 case 2:
10976
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 15 times.
59 if(misc==1)
10977 {
10978 15 dir=down;
10979 15 step=8;
10980 15 }
10981
10982
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 45 times.
59 if(misc<=2)
10983 {
10984 45 move(step);
10985 /*
10986 if(!canmove(dir,(zfix)0,0,false))
10987 dir=up;
10988 */
10989 45 }
10990
10991
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 14 times.
59 if(misc==3)
10992 {
10993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(canmove(left,(zfix)16,0,false))
10994 14 x-=16;
10995 14 }
10996
10997 59 ++misc;
10998 59 break;
10999
11000 default:
11001
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 28 times.
108 if(misc==1)
11002 {
11003 28 dir=(zc_oldrand()%4);
11004 28 step=8;
11005 28 }
11006
11007
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 83 times.
108 if(misc<=2)
11008 {
11009 83 move(step);
11010
11011
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 2 times.
83 if(!canmove(dir,(zfix)0,0,false))
11012 2 dir=dir^1;
11013 83 }
11014
11015
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 25 times.
108 if(misc==3)
11016 {
11017
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
25 if(dir >= left && canmove(dir,(zfix)16,0,false))
11018 8 x+=(dir==left ? -16 : 16);
11019 25 }
11020
11021 108 ++misc;
11022 108 break;
11023 14118397 }
11024
11025
4/4
✓ Branch 0 taken 25272 times.
✓ Branch 1 taken 14932595 times.
✓ Branch 2 taken 24443 times.
✓ Branch 3 taken 829 times.
14957867 if(id>>12 && misc>=4) //recently spawned by a split enemy
11026 {
11027 829 id&=0xFFF;
11028 829 step = zslongToFix(dstep*100);
11029
11030
1/2
✓ Branch 0 taken 829 times.
✗ Branch 1 not taken.
829 if(x<32) x=32;
11031
11032
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 21 times.
829 if(x>world_w-48) x=world_w-48;
11033
11034
2/2
✓ Branch 0 taken 805 times.
✓ Branch 1 taken 24 times.
829 if(y<32) y=32;
11035
11036
2/2
✓ Branch 0 taken 822 times.
✓ Branch 1 taken 7 times.
829 if(y>world_h-48) y=world_h-48;
11037
11038 829 misc=3;
11039 829 }
11040 14957867 }
11041 else
11042 {
11043 //sfx(wpnsfx(wpn),pan(x));
11044
1/2
✓ Branch 0 taken 432836 times.
✗ Branch 1 not taken.
432836 if(clk2>2) clk2--;
11045 }
11046
11047 // Fire Zol
11048
8/8
✓ Branch 0 taken 6104972 times.
✓ Branch 1 taken 9292938 times.
✓ Branch 2 taken 139281 times.
✓ Branch 3 taken 5965691 times.
✓ Branch 4 taken 1131 times.
✓ Branch 5 taken 138150 times.
✓ Branch 6 taken 1102 times.
✓ Branch 7 taken 29 times.
15397910 if(wpn && dmisc1==e1tEACHTILE && clk2==1 && !hclk)
11049 {
11050 1102 addEwpn(x,y,z,wpn,0,wdp,dir, getUID(), 0, fakez);
11051 1102 sfx(wpnsfx(wpn),pan(x));
11052
11053 1102 int32_t i=Ewpns.Count()-1;
11054 1102 weapon *ew = (weapon*)(Ewpns.spr(i));
11055
11056
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1102 if(wpn==ewFIRETRAIL && wpnsbuf[ewFIRETRAIL].frames>1)
11057 {
11058 ew->aframe=zc_oldrand()%wpnsbuf[ewFIRETRAIL].frames;
11059 if ( ew->do_animation ) ew->tile+=ew->aframe;
11060 }
11061 1102 }
11062 // Goriya
11063
14/16
✓ Branch 0 taken 1048873 times.
✓ Branch 1 taken 14347935 times.
✓ Branch 2 taken 468534 times.
✓ Branch 3 taken 580339 times.
✓ Branch 4 taken 456235 times.
✓ Branch 5 taken 12299 times.
✓ Branch 6 taken 423258 times.
✓ Branch 7 taken 32977 times.
✓ Branch 8 taken 423258 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 420517 times.
✓ Branch 11 taken 2741 times.
✓ Branch 12 taken 420517 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 414155 times.
✓ Branch 15 taken 6362 times.
15396808 else if(wpn==ewBrang && clk2==1 && sclk==0 && !stunclk && !frozenclock && !watch && wpn && !WeaponOut())
11064 {
11065 6362 misc=index+100;
11066
7/14
✓ Branch 0 taken 6362 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6362 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6362 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6362 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6362 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6362 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 6362 times.
✗ Branch 13 not taken.
6362 Ewpns.add(new weapon(x,y-fakez,z,wpn,misc,wdp,dir, -1,getUID(),false));
11067 6362 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=false;
11068
11069
2/2
✓ Branch 0 taken 6105 times.
✓ Branch 1 taken 257 times.
6362 if(dmisc1==2)
11070 {
11071 257 int32_t ndir=dir;
11072
11073
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 251 times.
257 if(Hero.x-x==0)
11074 {
11075 6 ndir=(Hero.y+8<y)?up:down;
11076 6 }
11077 else //turn to face Hero
11078 {
11079 double _MSVC2022_tmp1, _MSVC2022_tmp2;
11080 251 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
11081
11082
4/4
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 193 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 13 times.
251 if((ddir<=(((-2)*PI)/8))&&(ddir>(((-6)*PI)/8)))
11083 {
11084 13 ndir=down;
11085 13 }
11086
4/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 68 times.
238 else if((ddir<=(((2)*PI)/8))&&(ddir>(((-2)*PI)/8)))
11087 {
11088 68 ndir=right;
11089 68 }
11090
4/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 48 times.
170 else if((ddir<=(((6)*PI)/8))&&(ddir>(((2)*PI)/8)))
11091 {
11092 48 ndir=up;
11093 48 }
11094 else
11095 {
11096 122 ndir=left;
11097 }
11098 }
11099
11100 257 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=true;
11101
11102
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 223 times.
257 if(canmove(ndir,false))
11103 {
11104 223 dir=ndir;
11105 223 }
11106 257 }
11107 6362 }
11108
15/16
✓ Branch 0 taken 15331557 times.
✓ Branch 1 taken 58889 times.
✓ Branch 2 taken 221201 times.
✓ Branch 3 taken 15169245 times.
✓ Branch 4 taken 195083 times.
✓ Branch 5 taken 26118 times.
✓ Branch 6 taken 170191 times.
✓ Branch 7 taken 24892 times.
✓ Branch 8 taken 168807 times.
✓ Branch 9 taken 1384 times.
✓ Branch 10 taken 153707 times.
✓ Branch 11 taken 15100 times.
✓ Branch 12 taken 153707 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 944 times.
✓ Branch 15 taken 152763 times.
15390446 else if((clk2==16 || dmisc1==e1tCONSTANT) && dmisc1!=e1tEACHTILE && wpn && wpn!=ewBrang && sclk==0 && !stunclk && !frozenclock && !watch)
11109
3/3
✓ Branch 0 taken 26125 times.
✓ Branch 1 taken 125732 times.
✓ Branch 2 taken 906 times.
152763 switch(dmisc1)
11110 {
11111 case e1tCONSTANT: //Deathnut
11112 {
11113 // Overloading clk5 (Like Like clock) to avoid making another clock just for this attack...
11114
2/2
✓ Branch 0 taken 123149 times.
✓ Branch 1 taken 2583 times.
125732 if(clk5>64)
11115 {
11116 2583 clk5=0;
11117 2583 fired=false;
11118 2583 }
11119
11120 125732 clk5+=(zc_oldrand()&3);
11121
11122
4/4
✓ Branch 0 taken 76714 times.
✓ Branch 1 taken 49018 times.
✓ Branch 2 taken 25645 times.
✓ Branch 3 taken 51069 times.
125732 if((clk5>24)&&(clk5<52))
11123 {
11124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51069 times.
51069 if ( do_animation )tile+=20; //firing
11125
11126
4/4
✓ Branch 0 taken 27958 times.
✓ Branch 1 taken 23111 times.
✓ Branch 2 taken 25131 times.
✓ Branch 3 taken 2827 times.
51069 if(!fired&&(clk5>=38))
11127 {
11128
5/10
✓ Branch 0 taken 2827 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2827 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2827 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2827 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2827 times.
✗ Branch 9 not taken.
2827 Ewpns.add(new weapon(x,y,z, wpn, 0, wdp, dir, -1,getUID(),false));
11129 2827 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
11130 2827 sfx(wpnsfx(wpn),pan(x));
11131 2827 fired=true;
11132 2827 }
11133 51069 }
11134
11135 125732 break;
11136 }
11137
11138 case e1tFIREOCTO: //Fire Octo
11139 906 timer=zc_oldrand()%50+50;
11140 906 break;
11141
11142 default:
11143 26125 FireWeapon();
11144 26125 break;
11145 152763 }
11146
11147 /* Fire again if:
11148 * - clk2 about to run out
11149 * - not already double-firing (dmisc1 is 1)
11150 * - not carrying Hero
11151 * - one in 0xF chance
11152 */
11153
8/10
✓ Branch 0 taken 524941 times.
✓ Branch 1 taken 14872969 times.
✓ Branch 2 taken 4002 times.
✓ Branch 3 taken 520939 times.
✓ Branch 4 taken 4002 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4002 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3751 times.
✓ Branch 9 taken 251 times.
15397910 if(clk2==1 && (multishot < dmisc6) && dmisc1 != e1tEACHTILE && !hashero && !(zc_oldrand()&15))
11154 {
11155 #if 1
11156 251 newdir(rate, homing, grumble);
11157 #else
11158 dir^=2;
11159 #endif
11160 251 clk2=28;
11161 251 ++multishot;
11162 251 }
11163
11164
2/2
✓ Branch 0 taken 3492813 times.
✓ Branch 1 taken 11905097 times.
15397910 if(clk2==0)
11165 {
11166 11905097 multishot = 0;
11167 11905097 }
11168
11169
2/2
✓ Branch 0 taken 15333600 times.
✓ Branch 1 taken 64310 times.
15397910 if(timer) //Fire Octo
11170 {
11171 64310 clk2=15; //this keeps the octo in place until he's done firing
11172
11173
2/2
✓ Branch 0 taken 48558 times.
✓ Branch 1 taken 15752 times.
64310 if(!(timer%4))
11174 {
11175 15752 FireBreath(false);
11176 15752 }
11177
11178 64310 --timer;
11179 64310 }
11180
11181
2/2
✓ Branch 0 taken 15148517 times.
✓ Branch 1 taken 249393 times.
15397910 if(dmisc2==e2tTRIBBLE)
11182 249393 ++clk4;
11183
11184
7/10
✓ Branch 0 taken 4480 times.
✓ Branch 1 taken 15393430 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 15397217 times.
✓ Branch 4 taken 693 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 693 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 693 times.
15397910 if(clk4==(dmisc5 ? dmisc5 : 256) && (dmisc2==e2tTRIBBLE) && dmisc3 && dmisc4)
11185 {
11186 693 int32_t kids = guys.Count();
11187 693 int32_t id2=dmisc3;
11188
11189
2/2
✓ Branch 0 taken 693 times.
✓ Branch 1 taken 693 times.
1386 for(int32_t i=0; i<dmisc4; i++)
11190 {
11191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 693 times.
693 if(addenemy(screen_spawned,x,y,id2,-24))
11192 {
11193
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(itemguy) // Hand down the carried item
11194 {
11195 int guycarryingitem = guys.Count()-1;
11196 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11197 itemguy = false;
11198 }
11199
11200 693 ((enemy*)guys.spr(kids+i))->count_enemy = false;
11201 693 }
11202 693 }
11203
11204
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(hashero)
11205 {
11206 Hero.setEaten(0);
11207 hashero=false;
11208 }
11209
11210 693 stop_bgsfx(index);
11211 693 return true;
11212 }
11213
11214 15397217 return enemy::animate(index);
11215 15823224 }
11216
11217 16245517 void eStalfos::draw(BITMAP *dest)
11218 {
11219 16245517 update_enemy_frame();
11220
11221
7/8
✓ Branch 0 taken 16245091 times.
✓ Branch 1 taken 426 times.
✓ Branch 2 taken 16245091 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 86951 times.
✓ Branch 5 taken 16158140 times.
✓ Branch 6 taken 75836 times.
✓ Branch 7 taken 11115 times.
16245517 if(!fallclk&&!drownclk&&(dmisc2==e2tBOMBCHU)&&dashing)
11222 {
11223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11115 times.
11115 if ( do_animation )tile+=20;
11224 11115 }
11225
11226 16245517 enemy::draw(dest);
11227 16245517 }
11228
11229 7536565 void eStalfos::drawshadow(BITMAP *dest, bool translucent)
11230 {
11231 7536565 int32_t tempy=yofs;
11232
11233
4/4
✓ Branch 0 taken 7321147 times.
✓ Branch 1 taken 215418 times.
✓ Branch 2 taken 7224946 times.
✓ Branch 3 taken 311619 times.
7536565 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_ENEMIESZAXIS))
11234 {
11235 311619 flip = 0;
11236 311619 int32_t fdiv = frate/4;
11237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 311619 times.
311619 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11238
11239
1/2
✓ Branch 0 taken 311619 times.
✗ Branch 1 not taken.
311619 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11240 311619 efrate:((clk>=(frate>>1))?1:0);
11241 311619 shadowtile = wpnsbuf[spr_shadow].tile;
11242
11243
1/2
✓ Branch 0 taken 311619 times.
✗ Branch 1 not taken.
311619 if(get_qr(qr_NEWENEMYTILES))
11244 {
11245 311619 shadowtile+=f2;
11246 311619 }
11247 else
11248 {
11249 shadowtile+=f2?1:0;
11250 }
11251
11252 311619 yofs+=shadowdistance;
11253 311619 yofs+=8;
11254 311619 }
11255
4/4
✓ Branch 0 taken 7321147 times.
✓ Branch 1 taken 215418 times.
✓ Branch 2 taken 7533530 times.
✓ Branch 3 taken 3035 times.
7536565 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_POLVIRE_NO_SHADOW))
11256 {
11257 3035 flip = 0;
11258 3035 int32_t fdiv = frate/4;
11259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3035 times.
3035 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11260
11261
1/2
✓ Branch 0 taken 3035 times.
✗ Branch 1 not taken.
3035 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11262 3035 efrate:((clk>=(frate>>1))?1:0);
11263 3035 shadowtile = wpnsbuf[spr_shadow].tile;
11264
11265
1/2
✓ Branch 0 taken 3035 times.
✗ Branch 1 not taken.
3035 if(get_qr(qr_NEWENEMYTILES))
11266 {
11267 3035 shadowtile+=f2;
11268 3035 }
11269 else
11270 {
11271 shadowtile+=f2?1:0;
11272 }
11273 3035 }
11274
2/2
✓ Branch 0 taken 5496 times.
✓ Branch 1 taken 7531069 times.
7536565 if(!shadow_overpit(this))
11275 7531069 enemy::drawshadow(dest, translucent);
11276 7536565 yofs=tempy;
11277 7536565 }
11278
11279 157815 int32_t eStalfos::takehit(weapon *w, weapon* realweap)
11280 {
11281 157815 int32_t wpnId = w->id;
11282 157815 int32_t wpnDir = w->dir;
11283
11284
4/4
✓ Branch 0 taken 1418 times.
✓ Branch 1 taken 156397 times.
✓ Branch 2 taken 609 times.
✓ Branch 3 taken 809 times.
157815 if(wpnId==wHammer && shield && (flags & guy_bkshield)
11285
6/8
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 224 times.
✓ Branch 2 taken 385 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 265 times.
✓ Branch 5 taken 120 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 120 times.
609 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
11286
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 120 times.
120 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
11287 {
11288 265 shield = false;
11289 265 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
11290
11291
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 243 times.
265 if(get_qr(qr_BRKNSHLDTILES))
11292 243 o_tile=s_tile;
11293 265 }
11294
11295 157815 int32_t ret = enemy::takehit(w,realweap);
11296
11297
4/4
✓ Branch 0 taken 22327 times.
✓ Branch 1 taken 135488 times.
✓ Branch 2 taken 20576 times.
✓ Branch 3 taken 1751 times.
157815 if(sclk && dmisc2==e2tSPLITHIT)
11298 1751 sclk+=128; //Fuck these arbitrary values with no explanation. Fuck vires, too. -Z
11299
11300 157815 return ret;
11301 }
11302
11303 984687 void eStalfos::charge_attack()
11304 {
11305
2/2
✓ Branch 0 taken 6715 times.
✓ Branch 1 taken 977972 times.
984687 if(slide())
11306 6715 return;
11307
11308
10/12
✓ Branch 0 taken 977972 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 975568 times.
✓ Branch 3 taken 2404 times.
✓ Branch 4 taken 946055 times.
✓ Branch 5 taken 29513 times.
✓ Branch 6 taken 924502 times.
✓ Branch 7 taken 21553 times.
✓ Branch 8 taken 918879 times.
✓ Branch 9 taken 5623 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 918879 times.
977972 if(clk<0 || dir<0 || stunclk || watch || ceiling || frozenclock )
11309 59093 return;
11310
11311
2/2
✓ Branch 0 taken 37515 times.
✓ Branch 1 taken 881364 times.
918879 if(clk3<=0)
11312 {
11313 37515 fix_coords(true);
11314
11315
2/2
✓ Branch 0 taken 10043 times.
✓ Branch 1 taken 27472 times.
37515 if(!dashing)
11316 {
11317 27472 int32_t ldir = lined_up(7,false);
11318
11319
4/4
✓ Branch 0 taken 3107 times.
✓ Branch 1 taken 24365 times.
✓ Branch 2 taken 456 times.
✓ Branch 3 taken 2651 times.
27472 if(ldir!=-1 && canmove(ldir,false))
11320 {
11321 2651 dir=ldir;
11322 2651 dashing=true;
11323
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2651 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2651 if (dmisc10<=0 || replay_version_check(0,33) || get_qr(qr_ROPE_ENEMIES_SPEED_NOT_CONFIGURABLE))
11324 2651 step=zslongToFix(dstep*100)+1;
11325 else
11326 step=zslongToFix(dmisc10*100);
11327 2651 }
11328 24821 else newdir(4,0,0);
11329 27472 }
11330
11331
2/2
✓ Branch 0 taken 36061 times.
✓ Branch 1 taken 1454 times.
37515 if(!canmove(dir,false))
11332 {
11333 1454 step=zslongToFix(dstep*100);
11334 1454 newdir();
11335 1454 dashing=false;
11336 1454 }
11337
11338 37515 zfix div = step;
11339
11340
1/2
✓ Branch 0 taken 37515 times.
✗ Branch 1 not taken.
37515 if(div == 0)
11341 div = 1;
11342
11343 37515 clk3=(int32_t)(16.0/div);
11344 37515 return;
11345 }
11346
11347 881364 move(step);
11348 881364 --clk3;
11349 984687 }
11350
11351 796110 void eStalfos::vire_hop()
11352 {
11353
2/2
✓ Branch 0 taken 379034 times.
✓ Branch 1 taken 417076 times.
796110 if(dmisc9!=e9tPOLSVOICE)
11354 {
11355
2/2
✓ Branch 0 taken 372449 times.
✓ Branch 1 taken 6585 times.
379034 if(sclk!=0)
11356 {
11357
2/2
✓ Branch 0 taken 2742 times.
✓ Branch 1 taken 3843 times.
6585 if (dmisc2==e2tSPLITHIT) return;
11358 3843 }
11359 376292 }
11360 417076 else sclk=0;
11361
11362
8/12
✓ Branch 0 taken 793368 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 793368 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 777885 times.
✓ Branch 5 taken 15483 times.
✓ Branch 6 taken 761476 times.
✓ Branch 7 taken 16409 times.
✓ Branch 8 taken 761476 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 761476 times.
793368 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
11363 31892 return;
11364
11365 761476 int32_t jump_width = (dmisc9==e9tPOLSVOICE) ? 2 : 1;
11366 int32_t jump_height;
11367
11368
1/2
✓ Branch 0 taken 761476 times.
✗ Branch 1 not taken.
761476 if ((dmisc10 <= 0))
11369 761476 jump_height = (dmisc9 == e9tPOLSVOICE) ? 27 : 16;
11370 else jump_height = dmisc10;
11371
11372 761476 y=floor_y;
11373
11374
2/2
✓ Branch 0 taken 735218 times.
✓ Branch 1 taken 26258 times.
761476 if(clk3<=0)
11375 {
11376 26258 fix_coords();
11377
11378 //z=0;
11379 //if we're not in the middle of a jump or if we can't complete the current jump in the current direction
11380 //if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && isOnSideviewPlatform()))
11381
9/10
✓ Branch 0 taken 4922 times.
✓ Branch 1 taken 21336 times.
✓ Branch 2 taken 4320 times.
✓ Branch 3 taken 602 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 4226 times.
✓ Branch 6 taken 42 times.
✓ Branch 7 taken 52 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 42 times.
26258 if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && (isOnSideviewPlatform() || !(moveflags & move_obeys_grav)))) //Vires in old quests
11382 22032 newdir(rate,homing,dmisc9==e9tPOLSVOICE ? spw_floater : spw_none);
11383
11384
2/2
✓ Branch 0 taken 4922 times.
✓ Branch 1 taken 21336 times.
26258 if(clk2<=0)
11385 {
11386 //z=0;
11387
6/6
✓ Branch 0 taken 19015 times.
✓ Branch 1 taken 2321 times.
✓ Branch 2 taken 18569 times.
✓ Branch 3 taken 446 times.
✓ Branch 4 taken 14491 times.
✓ Branch 5 taken 4078 times.
21336 if(!canmove(dir,(zfix)2,spw_none,false) || m_walkflag(x,y,spw_none, dir) || (zc_oldrand()&15)>=hrate)
11388 {
11389
11390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17258 times.
17258 clk2=(wpn==ewBrang ? 1 : int32_t((16.0*jump_width)/step.getFloat()));
11391 17258 }
11392 21336 }
11393
11394
4/4
✓ Branch 0 taken 12099 times.
✓ Branch 1 taken 14159 times.
✓ Branch 2 taken 5069 times.
✓ Branch 3 taken 7030 times.
26258 if(dmisc9!=e9tPOLSVOICE && dir>=left) //if we're moving left or right
11395 {
11396 7030 clk2=int32_t((16.0*jump_width)/step.getFloat());
11397 7030 }
11398
11399 26258 clk3=int32_t(16.0/step.getFloat());
11400 26258 }
11401
11402 761476 --clk3;
11403
11404
3/4
✓ Branch 0 taken 361067 times.
✓ Branch 1 taken 400409 times.
✓ Branch 2 taken 361067 times.
✗ Branch 3 not taken.
761476 if(dmisc9==e9tPOLSVOICE || clk2>0)
11405 761476 move(step);
11406
11407 761476 floor_y=y;
11408 761476 clk2--;
11409
11410 //if we're in the middle of a jump
11411
6/6
✓ Branch 0 taken 624929 times.
✓ Branch 1 taken 136547 times.
✓ Branch 2 taken 257704 times.
✓ Branch 3 taken 367225 times.
✓ Branch 4 taken 110653 times.
✓ Branch 5 taken 147051 times.
761476 if(clk2>0 && (dir>=left || dmisc9==e9tPOLSVOICE))
11412 {
11413 477878 int32_t h = fixtoi(fixsin(itofix(clk2*128*step/(16*jump_width)))*jump_height);
11414
11415
4/4
✓ Branch 0 taken 99298 times.
✓ Branch 1 taken 378580 times.
✓ Branch 2 taken 6151 times.
✓ Branch 3 taken 93147 times.
477878 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11416 {
11417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93147 times.
93147 if (moveflags & move_use_fake_z) fakez=h;
11418 93147 else z=h;
11419 93147 }
11420 else
11421 {
11422 384731 y=floor_y-h;
11423 384731 shadowdistance=h;
11424 }
11425 477878 }
11426 else
11427 283598 shadowdistance = 0;
11428 796110 }
11429
11430 138 void eStalfos::eathero()
11431 {
11432
5/8
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 70 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 70 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 70 times.
138 if(!hashero && Hero.getEaten()==0 && Hero.getAction() != hopping && Hero.getAction() != swimming)
11433 {
11434 70 hashero=true;
11435 70 y=floor_y;
11436 70 z=0;
11437
11438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if(Hero.isSwimming())
11439 {
11440 Hero.setX(x);
11441 Hero.setY(y);
11442 }
11443 else
11444 {
11445 70 x=Hero.getX();
11446 70 y=Hero.getY();
11447 }
11448
11449 70 clk2=0;
11450 70 }
11451 138 }
11452
11453 1469390 bool eStalfos::WeaponOut()
11454 {
11455
2/2
✓ Branch 0 taken 2400579 times.
✓ Branch 1 taken 622399 times.
3022978 for(int32_t i=0; i<Ewpns.Count(); i++)
11456 {
11457
3/4
✓ Branch 0 taken 846991 times.
✓ Branch 1 taken 1553588 times.
✓ Branch 2 taken 846991 times.
✗ Branch 3 not taken.
2400579 if(((weapon*)Ewpns.spr(i))->parentid==getUID() && Ewpns.spr(i)->id==ewBrang)
11458 {
11459 846991 return true;
11460 }
11461 1553588 }
11462
11463 622399 return false;
11464 1469390 }
11465
11466 353022 void eStalfos::KillWeapon()
11467 {
11468
2/2
✓ Branch 0 taken 293384 times.
✓ Branch 1 taken 353022 times.
646406 for(int32_t i=0; i<Ewpns.Count(); i++)
11469 {
11470
4/4
✓ Branch 0 taken 245286 times.
✓ Branch 1 taken 48098 times.
✓ Branch 2 taken 244476 times.
✓ Branch 3 taken 810 times.
293384 if(((weapon*)Ewpns.spr(i))->level==misc && Ewpns.spr(i)->id==ewBrang)
11471 {
11472 //only kill this Goriya's boomerang -DD
11473
2/2
✓ Branch 0 taken 399 times.
✓ Branch 1 taken 411 times.
810 if(((weapon *)Ewpns.spr(i))->parentid == getUID())
11474 {
11475 411 Ewpns.del(i);
11476 411 }
11477 810 }
11478 293384 }
11479 353022 }
11480
11481 void eStalfos::break_shield()
11482 {
11483 if(!shield)
11484 return;
11485
11486 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
11487 shield=false;
11488
11489 if(get_qr(qr_BRKNSHLDTILES))
11490 o_tile=s_tile;
11491 }
11492
11493 void eStalfos::repair_shield()
11494 {
11495 if (shield)
11496 return;
11497
11498 shield = true;
11499
11500 if (get_qr(qr_BRKNSHLDTILES))
11501 {
11502 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
11503 else o_tile = d->tile;
11504 }
11505 }
11506
11507 13720 eKeese::eKeese(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11508 13720 {
11509
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 dir=(zc_oldrand()&7)+8;
11510
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 step=0;
11511 13720 movestatus=1;
11512
3/4
✓ Branch 0 taken 10596 times.
✓ Branch 1 taken 3124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10596 times.
13720 if (dmisc1 != 1 && dmisc19 > 0)
11513 {
11514 step = dmisc19/100.0;
11515 movestatus = 1;
11516 }
11517
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if (dmisc1 == 2) movestatus=2;
11518 13720 c=0;
11519 13720 clk4=0;
11520 //nets;
11521
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 init_size_flags();
11522 13720 dummy_int[1]=0;
11523 13720 }
11524
11525 3535341 bool eKeese::animate(int32_t index)
11526 {
11527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3535341 times.
3535341 if(switch_hooked) return enemy::animate(index);
11528
2/4
✓ Branch 0 taken 3535341 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3535341 times.
3535341 if(fallclk||drownclk) return enemy::animate(index);
11529
2/2
✓ Branch 0 taken 124509 times.
✓ Branch 1 taken 3410832 times.
3535341 if(dying)
11530 124509 return Dead(index);
11531
11532
2/2
✓ Branch 0 taken 3384641 times.
✓ Branch 1 taken 26191 times.
3410832 if(clk==0)
11533 {
11534 26191 removearmos(x,y);
11535 26191 }
11536
11537
2/2
✓ Branch 0 taken 1025042 times.
✓ Branch 1 taken 2385790 times.
3410832 if(dmisc1 == 1) //Walk style. 0 is keese, 1 is bat.
11538 {
11539 1025042 floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
11540 1025042 }
11541 else
11542 {
11543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2385790 times.
2385790 if (dmisc18) floater_walk(rate,hrate,dstep/100,dmisc18/100.0,-1,dmisc16,dmisc17);
11544 2385790 else floater_walk(rate,hrate,dstep/100,dstep/1000,10,dmisc16,dmisc17);
11545 }
11546
11547
2/2
✓ Branch 0 taken 120338 times.
✓ Branch 1 taken 3290494 times.
3410832 if(dmisc2 == e2tKEESETRIB)
11548 {
11549
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120338 times.
✓ Branch 2 taken 120147 times.
✓ Branch 3 taken 191 times.
120338 if(++clk4==(dmisc20>0?dmisc20:256))
11550 {
11551
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 105 times.
191 if(!m_walkflag(x,y,0, dir))
11552 {
11553 105 int32_t kids = guys.Count();
11554 105 bool success = false;
11555 105 int32_t id2=dmisc3;
11556 105 success = 0 != addenemy(screen_spawned,(zfix)x,(zfix)y,id2,-24);
11557
11558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(success)
11559 {
11560
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(itemguy) // Hand down the carried item
11561 {
11562 int guycarryingitem = guys.Count()-1;
11563 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11564 itemguy = false;
11565 }
11566
11567 105 ((enemy*)guys.spr(kids))->count_enemy = count_enemy;
11568 105 }
11569
11570 105 stop_bgsfx(index);
11571 105 return true;
11572 }
11573 else
11574 {
11575 86 clk4=0;
11576 }
11577 86 }
11578 120233 }
11579 // Keese Tribbles stay on the ground, so there's no problem when they transform.
11580
3/4
✓ Branch 0 taken 845879 times.
✓ Branch 1 taken 2444615 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 845879 times.
3290494 else if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11581 {
11582
2/2
✓ Branch 0 taken 687068 times.
✓ Branch 1 taken 158811 times.
845879 if (get_qr(qr_OLD_KEESE_Z_AXIS))
11583 {
11584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 687068 times.
687068 if (moveflags & move_use_fake_z)
11585 {
11586 fakez=int32_t(step/zslongToFix(dstep*100));
11587 // Some variance in keese flight heights when away from Hero
11588 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
11589
11590 }
11591 else
11592 {
11593 687068 z=int32_t(step/zslongToFix(dstep*100));
11594 // Some variance in keese flight heights when away from Hero
11595
2/2
✓ Branch 0 taken 503635 times.
✓ Branch 1 taken 183433 times.
687068 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
11596 }
11597 687068 }
11598 else
11599 {
11600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158811 times.
158811 if (moveflags & move_use_fake_z)
11601 {
11602 fakez=int32_t(step/zslongToFix(dstep*100));
11603 // Some variance in keese flight heights when away from Hero
11604 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
11605
11606 }
11607 else
11608 {
11609 158811 z=int32_t(step/zslongToFix(dstep*100));
11610 // Some variance in keese flight heights when away from Hero
11611
2/2
✓ Branch 0 taken 16841 times.
✓ Branch 1 taken 141970 times.
158811 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
11612 }
11613 }
11614 845879 }
11615
11616 3410727 return enemy::animate(index);
11617 3535341 }
11618
11619 2088281 void eKeese::drawshadow(BITMAP *dest, bool translucent)
11620 {
11621 2088281 int32_t tempy=yofs;
11622 2088281 flip = 0;
11623 2088281 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
11624
11625
2/2
✓ Branch 0 taken 667695 times.
✓ Branch 1 taken 1420586 times.
2088281 yofs+=zc_min(int32_t(step/zslongToFix(dstep*10)), 8);
11626
2/2
✓ Branch 0 taken 690563 times.
✓ Branch 1 taken 1397718 times.
2088281 if(!get_qr(qr_ENEMIESZAXIS))
11627 {
11628 1397718 yofs+=int32_t(step/zslongToFix(dstep*10));
11629 1397718 }
11630
11631
6/6
✓ Branch 0 taken 2067591 times.
✓ Branch 1 taken 20690 times.
✓ Branch 2 taken 676820 times.
✓ Branch 3 taken 1390771 times.
✓ Branch 4 taken 661452 times.
✓ Branch 5 taken 15368 times.
2088281 if(!shadow_overpit(this) && (!get_qr(qr_ENEMIESZAXIS) || step > 0))
11632 2052223 enemy::drawshadow(dest, translucent);
11633 2088281 yofs=tempy;
11634 2088281 }
11635
11636 7949863 void eKeese::draw(BITMAP *dest)
11637 {
11638 7949863 update_enemy_frame();
11639 7949863 enemy::draw(dest);
11640 7949863 }
11641
11642 13720 void eKeese::init_size_flags()
11643 {
11644 13720 SIZEflags = d->SIZEflags;
11645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
13720 if (!(SIZEflags & OVERRIDE_HIT_X_OFFSET)) hxofs = 2;
11646
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
11647
11648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
13720 if (!(SIZEflags & OVERRIDE_HIT_WIDTH)) hit_width = 12;
11649
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13720 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
11650
11651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
13720 if (!(SIZEflags & OVERRIDE_HIT_Y_OFFSET)) hyofs = 4;
11652
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
11653
11654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
13720 if (!(SIZEflags & OVERRIDE_HIT_HEIGHT)) hit_height = 8;
11655
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13720 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
11656
11657
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13720 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11658 // al_trace("Enemy txsz:%i\n", txsz);
11659
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13720 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
11660
11661
11662
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13720 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
11663
11664
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
11665
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
11666 {
11667 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11668 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
11669 }
11670
11671
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
11672 13720 }
11673
11674 20171 void eWizzrobe::submerge(bool set)
11675 {
11676
2/2
✓ Branch 0 taken 20024 times.
✓ Branch 1 taken 147 times.
20171 if(get_qr(qr_OLD_WIZZROBE_SUBMERGING))
11677 {
11678 20024 hxofs = set?1000:0;
11679 20024 return;
11680 }
11681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
147 if(submerged == set) return;
11682 147 submerged = set;
11683
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 71 times.
147 if(set)
11684 76 hxofs+=1000;
11685 71 else hxofs -= 1000;
11686 20171 }
11687 5350 eWizzrobe::eWizzrobe(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11688 5350 {
11689 5350 hxofs = 0;
11690 5350 submerged = false;
11691
2/2
✓ Branch 0 taken 2358 times.
✓ Branch 1 taken 2992 times.
5350 switch(dmisc1)
11692 {
11693 case 0:
11694 2992 submerge(true);
11695 2992 fading=fade_invisible;
11696 // Set clk to just before the 'reappear' threshold
11697
9/10
✓ Branch 0 taken 2991 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2991 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1184 times.
✓ Branch 5 taken 1808 times.
✓ Branch 6 taken 1184 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1807 times.
✓ Branch 9 taken 1 times.
2992 clk=zc_min(clk+(146+zc_max(0,dmisc5))+14,(146+zc_max(0,dmisc5))-1);
11698 2992 break;
11699
11700 default:
11701 2358 dir=(loadside==right)?right:left;
11702 2358 misc=-3;
11703 2358 break;
11704 }
11705
11706 //netst+2880;
11707 5350 charging=false;
11708 5350 firing=false;
11709 5350 fclk=0;
11710
2/2
✓ Branch 0 taken 2358 times.
✓ Branch 1 taken 2992 times.
5350 if(!dmisc1) frate=1200+146; //1200 = 20 seconds
11711
1/4
✓ Branch 0 taken 5350 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5350 if (SIZEflags != 0) init_size_flags();;
11712 5350 }
11713
11714 2081613 bool eWizzrobe::animate(int32_t index)
11715 {
11716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2081613 times.
2081613 if(switch_hooked) return enemy::animate(index);
11717
2/4
✓ Branch 0 taken 2081613 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2081613 times.
2081613 if(fallclk||drownclk) return enemy::animate(index);
11718
2/2
✓ Branch 0 taken 38023 times.
✓ Branch 1 taken 2043590 times.
2081613 if(dying)
11719 {
11720 38023 return Dead(index);
11721 }
11722
11723
2/2
✓ Branch 0 taken 1976944 times.
✓ Branch 1 taken 66646 times.
2043590 if(clk==0)
11724 {
11725 66646 removearmos(x,y);
11726 66646 }
11727
11728
2/2
✓ Branch 0 taken 1019220 times.
✓ Branch 1 taken 1024370 times.
2043590 if(dmisc1) // Floating
11729 {
11730 1019220 wizzrobe_attack();
11731 1019220 }
11732 else // Teleporting
11733 {
11734
5/6
✓ Branch 0 taken 1017286 times.
✓ Branch 1 taken 7084 times.
✓ Branch 2 taken 11087 times.
✓ Branch 3 taken 1006199 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 11087 times.
1024370 if(watch || (!get_qr(qr_WIZZROBES_DONT_OBEY_STUN) && stunclk))
11735 {
11736 7084 fading=0;
11737 7084 submerge(false);
11738 7084 solid_update(false);
11739 7084 }
11740
8/8
✓ Branch 0 taken 983365 times.
✓ Branch 1 taken 6240 times.
✓ Branch 2 taken 5313 times.
✓ Branch 3 taken 5151 times.
✓ Branch 4 taken 5006 times.
✓ Branch 5 taken 4247 times.
✓ Branch 6 taken 4109 times.
✓ Branch 7 taken 3855 times.
1017286 else switch(clk)
11741 {
11742 case 0:
11743
2/2
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 5123 times.
6240 if(!dmisc2)
11744 {
11745 // Wizzrobe Misc4 controls whether wizzrobes can teleport on top of solid combos,
11746 // but should not appear on dungeon walls.
11747
2/2
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 4710 times.
5123 if ( FFCore.getQuestHeaderInfo(vZelda) <= 0x190 ) place_on_axis(true, false); //1.84, and probably 1.90 wizzrobes should NEVER appear in dungeon walls.-Z (1.84 confirmed, 15th January, 2019 by Chris Miller).
11748
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 4486 times.
4710 else if (editorflags&ENEMY_FLAG5)
11749 {
11750 //2.10 Windrobe
11751 //randomise location and face Hero
11752 224 int32_t t=0;
11753 224 bool placed=false;
11754
11755
4/4
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 367 times.
✓ Branch 2 taken 367 times.
✓ Branch 3 taken 224 times.
591 while(!placed && t<160)
11756 {
11757
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 87 times.
367 if(isdungeon(screen_spawned))
11758 {
11759 280 x=((zc_oldrand()%12)+2)*16;
11760 280 y=((zc_oldrand()%7)+2)*16;
11761 280 }
11762 else
11763 {
11764 87 x=((zc_oldrand()%14)+1)*16;
11765 87 y=((zc_oldrand()%9)+1)*16;
11766 }
11767
11768 367 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, x, y);
11769
11770
6/6
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 244 times.
✓ Branch 2 taken 187 times.
✓ Branch 3 taken 57 times.
✓ Branch 4 taken 143 times.
✓ Branch 5 taken 224 times.
611 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
11771 {
11772 224 placed=true;
11773 224 }
11774
11775 367 ++t;
11776 }
11777
11778
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 163 times.
224 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
11779 {
11780
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 14 times.
61 if(y<Hero.getY())
11781 {
11782 47 dir=down;
11783 47 }
11784 else
11785 {
11786 14 dir=up;
11787 }
11788 61 }
11789 else
11790 {
11791
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 72 times.
163 if(x<Hero.getX())
11792 {
11793 72 dir=right;
11794 72 }
11795 else
11796 {
11797 91 dir=left;
11798 }
11799 }
11800
11801
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 if(!placed) // can't place him, he's gone
11802 return true;
11803
11804
11805 //wizzrobe_attack(); //Complaint about 2.10 Windrobes not behaving as they did in 2.10. Let's try it this way. -Z
11806 //wizzrobe_attack_for_real(); //doing this makes them fire twice. The rest is correct.
11807 224 }
11808 4486 else place_on_axis(true, dmisc4!=0);
11809 5123 }
11810 else
11811 {
11812 1117 int32_t t=0;
11813 1117 bool placed=false;
11814
11815
4/4
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 2443 times.
✓ Branch 2 taken 2443 times.
✓ Branch 3 taken 1117 times.
3560 while(!placed && t<160)
11816 {
11817
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 1103 times.
2443 if(isdungeon(screen_spawned))
11818 {
11819 1340 x=((zc_oldrand()%12)+2)*16;
11820 1340 y=((zc_oldrand()%7)+2)*16;
11821 1340 }
11822 else
11823 {
11824 1103 x=((zc_oldrand()%14)+1)*16;
11825 1103 y=((zc_oldrand()%9)+1)*16;
11826 }
11827
11828 2443 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, x, y);
11829
11830
6/6
✓ Branch 0 taken 1130 times.
✓ Branch 1 taken 1313 times.
✓ Branch 2 taken 898 times.
✓ Branch 3 taken 415 times.
✓ Branch 4 taken 1326 times.
✓ Branch 5 taken 1117 times.
3756 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
11831 {
11832 1117 placed=true;
11833 1117 }
11834
11835 2443 ++t;
11836 }
11837
11838
2/2
✓ Branch 0 taken 386 times.
✓ Branch 1 taken 731 times.
1117 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
11839 {
11840
2/2
✓ Branch 0 taken 238 times.
✓ Branch 1 taken 148 times.
386 if(y<Hero.getY())
11841 {
11842 238 dir=down;
11843 238 }
11844 else
11845 {
11846 148 dir=up;
11847 }
11848 386 }
11849 else
11850 {
11851
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 391 times.
731 if(x<Hero.getX())
11852 {
11853 340 dir=right;
11854 340 }
11855 else
11856 {
11857 391 dir=left;
11858 }
11859 }
11860
11861
1/2
✓ Branch 0 taken 1117 times.
✗ Branch 1 not taken.
1117 if(!placed) // can't place him, he's gone
11862 return true;
11863 }
11864
11865 6240 fading=fade_flicker;
11866 6240 submerge(false);
11867 6240 solid_update(false);
11868 6240 break;
11869
11870 case 64:
11871 5313 fading=0;
11872 5313 charging=true;
11873 5313 break;
11874
11875 case 73:
11876 5151 charging=false;
11877 5151 firing=40;
11878 5151 break;
11879
11880 case 83:
11881 5006 wizzrobe_attack_for_real();
11882 5006 break;
11883
11884 case 119:
11885 4247 firing=false;
11886 4247 charging=true;
11887 4247 break;
11888
11889 case 128:
11890 4109 fading=fade_flicker;
11891 4109 charging=false;
11892 4109 break;
11893
11894 case 146:
11895 3855 fading=fade_invisible;
11896 3855 submerge(true);
11897 3855 solid_update(false);
11898
11899 [[fallthrough]];
11900 default:
11901
4/4
✓ Branch 0 taken 987060 times.
✓ Branch 1 taken 160 times.
✓ Branch 2 taken 980971 times.
✓ Branch 3 taken 6249 times.
987220 if(clk>=(146+zc_max(0,dmisc5)))
11902 6249 clk=-1;
11903
11904 987220 break;
11905 }
11906 }
11907
11908 2043590 return enemy::animate(index);
11909 2081613 }
11910
11911 7929 void eWizzrobe::wizzrobe_attack_for_real()
11912 {
11913
1/2
✓ Branch 0 taken 7929 times.
✗ Branch 1 not taken.
7929 if(wpn==0) // Edited enemies
11914 return;
11915
11916
2/2
✓ Branch 0 taken 1983 times.
✓ Branch 1 taken 5946 times.
7929 if(dmisc2 == 0) //normal weapon
11917 {
11918 5946 addEwpn(x,y,z,wpn,0,wdp,dir,getUID(), 0, fakez);
11919 5946 sfx(firesfx, pan(x));
11920 5946 }
11921
2/2
✓ Branch 0 taken 995 times.
✓ Branch 1 taken 988 times.
1983 else if(dmisc2 == 1) // ring of fire
11922 {
11923 995 addEwpn(x,y,z,wpn,0,wdp,up,getUID(), 0, fakez);
11924 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11925 995 addEwpn(x,y,z,wpn,0,wdp,down,getUID(), 0, fakez);
11926 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11927 995 addEwpn(x,y,z,wpn,0,wdp,left,getUID(), 0, fakez);
11928 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11929 995 addEwpn(x,y,z,wpn,0,wdp,right,getUID(), 0, fakez);
11930 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11931 995 addEwpn(x,y,z,wpn,0,wdp,l_up,getUID(), 0, fakez);
11932 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11933 995 addEwpn(x,y,z,wpn,0,wdp,r_up,getUID(), 0, fakez);
11934 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11935 995 addEwpn(x,y,z,wpn,0,wdp,l_down,getUID(), 0, fakez);
11936 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11937 995 addEwpn(x,y,z,wpn,0,wdp,r_down,getUID(), 0, fakez);
11938 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11939 //this block of code was buggy and flat out doesn't match the default wpnsfx for these weapons.
11940 //i've compromised by making all old quest use this code chunk by default.
11941
1/2
✓ Branch 0 taken 995 times.
✗ Branch 1 not taken.
995 if (FFCore.quest_format[vGuys] < 51)
11942 {
11943 995 sfx(WAV_FIRE, pan(x));
11944
2/2
✓ Branch 0 taken 488 times.
✓ Branch 1 taken 507 times.
995 if (get_qr(qr_8WAY_SHOT_SFX_DEP)) sfx(WAV_FIRE,pan(x));
11945 else
11946 {
11947
3/17
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 68 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 420 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
507 switch (wpn)
11948 {
11949 19 case ewFireball: sfx(40, pan(x)); break;
11950 case ewBrang: sfx(4, pan(x)); break; //Ghost.zh has 0?
11951 case ewSword: sfx(20, pan(x)); break; //Ghost.zh has 0?
11952 case ewRock: sfx(51, pan(x)); break;
11953 68 case ewMagic: sfx(32, pan(x)); break;
11954 case ewBomb: sfx(3, pan(x)); break; //Ghost.zh has 0?
11955 case ewSBomb: sfx(3, pan(x)); break; //Ghost.zh has 0?
11956 case ewLitBomb: sfx(21, pan(x)); break; //Ghost.zh has 0?
11957 case ewLitSBomb: sfx(21, pan(x)); break; //Ghost.zh has 0?
11958 case ewFireTrail: sfx(13, pan(x)); break;
11959 420 case ewFlame: sfx(13, pan(x)); break;
11960 case ewWind: sfx(32, pan(x)); break;
11961 case ewFlame2: sfx(13, pan(x)); break;
11962 case ewFlame2Trail: sfx(13, pan(x)); break;
11963 case ewIce: sfx(44, pan(x)); break;
11964 case ewFireball2: sfx(40, pan(x)); break; //fireball (rising)
11965 default: sfx(WAV_FIRE, pan(x)); break;
11966 }
11967 }
11968 995 }
11969 else
11970 {
11971 sfx(firesfx, pan(x));
11972 }
11973 995 }
11974
2/2
✓ Branch 0 taken 971 times.
✓ Branch 1 taken 17 times.
988 else if(dmisc2==2) // summons specific enemy
11975 {
11976 971 int32_t bc=0;
11977
11978
2/2
✓ Branch 0 taken 10497 times.
✓ Branch 1 taken 971 times.
11468 for(int32_t gc=0; gc<guys.Count(); gc++)
11979 {
11980
2/2
✓ Branch 0 taken 5302 times.
✓ Branch 1 taken 5195 times.
10497 if((((enemy*)guys.spr(gc))->id) == dmisc3)
11981 {
11982 5195 ++bc;
11983 5195 }
11984 10497 }
11985
11986
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 963 times.
971 if(bc<=40)
11987 {
11988 963 int32_t kids = guys.Count();
11989 963 int32_t bats=(zc_oldrand()%3)+1;
11990
11991
2/2
✓ Branch 0 taken 1965 times.
✓ Branch 1 taken 963 times.
2928 for(int32_t i=0; i<bats; i++)
11992 {
11993 // Summon bats (or anything)
11994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1965 times.
1965 if(addchild(screen_spawned, x,y,dmisc3,-10, this))
11995 1965 ((enemy*)guys.spr(kids+i))->count_enemy = false;
11996 1965 }
11997 963 sfx(firesfx, pan(x));
11998 963 }
11999 971 }
12000
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 else if(dmisc2==3) //summon from layer
12001 {
12002
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(count_layer_enemies(screen_spawned)==0)
12003 {
12004 return;
12005 }
12006
12007 17 int32_t kids = guys.Count();
12008
12009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(kids<200)
12010 {
12011 17 int32_t newguys=(zc_oldrand()%3)+1;
12012 17 bool summoned=false;
12013
12014
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 17 times.
49 for(int32_t i=0; i<newguys; i++)
12015 {
12016 32 int32_t id2=vbound(random_layer_enemy(screen_spawned),eSTART,eMAXGUYS-1);
12017 32 int32_t x2=0;
12018 32 int32_t y2=0;
12019
12020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 for(int32_t k=0; k<20; ++k)
12021 {
12022 36 x2=16*((zc_oldrand()%12)+2);
12023 36 y2=16*((zc_oldrand()%7)+2);
12024
12025
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 32 times.
72 if(!m_walkflag(x2,y2,0, dir) && (abs(x2-Hero.getX())>=32 || abs(y2-Hero.getY())>=32))
12026 {
12027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(addchild_z(screen_spawned,x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this))
12028 {
12029 32 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12030
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
32 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & move_use_fake_z))
12031 {
12032 ((enemy*)guys.spr(kids+i))->fakez = 64;
12033 ((enemy*)guys.spr(kids+i))->z = 0;
12034 }
12035 32 }
12036
12037 32 summoned=true;
12038 32 break;
12039 }
12040 4 }
12041 32 }
12042
12043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(summoned)
12044 {
12045 17 sfx(firesfx, pan(x));
12046 17 }
12047 17 }
12048 17 }
12049 7929 }
12050
12051
12052 1019220 void eWizzrobe::wizzrobe_attack()
12053 {
12054
10/12
✓ Branch 0 taken 982487 times.
✓ Branch 1 taken 36733 times.
✓ Branch 2 taken 982487 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 937882 times.
✓ Branch 5 taken 44605 times.
✓ Branch 6 taken 934499 times.
✓ Branch 7 taken 3383 times.
✓ Branch 8 taken 932879 times.
✓ Branch 9 taken 1620 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 932879 times.
1019220 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
12055 86341 return;
12056
12057
3/8
✓ Branch 0 taken 893341 times.
✓ Branch 1 taken 39538 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 893341 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
932879 if(clk3<=0 || ((clk3&31)==0 && !canmove(dir,(zfix)1,spw_door,false) && !misc))
12058 {
12059 39538 fix_coords();
12060
12061
5/5
✓ Branch 0 taken 5496 times.
✓ Branch 1 taken 1050 times.
✓ Branch 2 taken 16081 times.
✓ Branch 3 taken 13008 times.
✓ Branch 4 taken 3903 times.
39538 switch(misc)
12062 {
12063 case 1: //walking
12064
2/2
✓ Branch 0 taken 10364 times.
✓ Branch 1 taken 2644 times.
13008 if(!m_walkflag(x,y,spw_door, dir))
12065 2644 misc=0;
12066 else
12067 {
12068 10364 clk3=16;
12069
12070
2/2
✓ Branch 0 taken 8966 times.
✓ Branch 1 taken 1398 times.
10364 if(!canmove(dir,(zfix)1,spw_wizzrobe,false))
12071 {
12072 1398 wizzrobe_newdir(0);
12073 1398 }
12074 }
12075
12076 13008 break;
12077
12078 case 2: //phasing
12079 {
12080 3903 int32_t jx=x;
12081 3903 int32_t jy=y;
12082 3903 int32_t jdir=-1;
12083
12084
5/5
✓ Branch 0 taken 1973 times.
✓ Branch 1 taken 484 times.
✓ Branch 2 taken 472 times.
✓ Branch 3 taken 482 times.
✓ Branch 4 taken 492 times.
3903 switch(zc_oldrand()&7)
12085 {
12086 case 0:
12087 484 jx-=32;
12088 484 jy-=32;
12089 484 jdir=15;
12090 484 break;
12091
12092 case 1:
12093 472 jx+=32;
12094 472 jy-=32;
12095 472 jdir=9;
12096 472 break;
12097
12098 case 2:
12099 482 jx+=32;
12100 482 jy+=32;
12101 482 jdir=11;
12102 482 break;
12103
12104 case 3:
12105 492 jx-=32;
12106 492 jy+=32;
12107 492 jdir=13;
12108 492 break;
12109 }
12110
12111
10/10
✓ Branch 0 taken 1930 times.
✓ Branch 1 taken 1973 times.
✓ Branch 2 taken 1724 times.
✓ Branch 3 taken 206 times.
✓ Branch 4 taken 1597 times.
✓ Branch 5 taken 127 times.
✓ Branch 6 taken 1385 times.
✓ Branch 7 taken 212 times.
✓ Branch 8 taken 1140 times.
✓ Branch 9 taken 245 times.
3903 if(jdir>0 && jx>=32 && jx<=208 && jy>=32 && jy<=128)
12112 {
12113 1140 misc=3;
12114 1140 clk3=32;
12115 1140 dir=jdir;
12116 1140 break;
12117 }
12118 2763 }
12119 [[fallthrough]];
12120 case 3:
12121 3813 dir&=3;
12122 3813 misc=0;
12123 [[fallthrough]];
12124 case 0:
12125 19894 wizzrobe_newdir(64);
12126 [[fallthrough]];
12127 default:
12128
2/2
✓ Branch 0 taken 21886 times.
✓ Branch 1 taken 3504 times.
25390 if(!canmove(dir,(zfix)1,spw_door,false))
12129 {
12130
2/2
✓ Branch 0 taken 3265 times.
✓ Branch 1 taken 239 times.
3504 if(canmove(dir,(zfix)15,spw_wizzrobe,false))
12131 {
12132 3265 misc=1;
12133 3265 clk3=16;
12134 3265 }
12135 else
12136 {
12137 239 wizzrobe_newdir(64);
12138 239 misc=0;
12139 239 clk3=32;
12140 }
12141 3504 }
12142 else
12143 {
12144 21886 clk3=32;
12145 }
12146
12147 25390 break;
12148 }
12149
12150
2/2
✓ Branch 0 taken 35060 times.
✓ Branch 1 taken 4478 times.
39538 if(misc<0)
12151 4478 ++misc;
12152 39538 }
12153
12154 932879 --clk3;
12155
12156
3/3
✓ Branch 0 taken 248377 times.
✓ Branch 1 taken 620599 times.
✓ Branch 2 taken 63903 times.
932879 switch(misc)
12157 {
12158 case 1:
12159 case 3:
12160 248377 step=1;
12161 248377 break;
12162
12163 case 2:
12164 63903 step=0;
12165 63903 break;
12166
12167 default:
12168 620599 step=0.5;
12169 620599 break;
12170
12171 }
12172
12173 932879 move(step);
12174
12175 // if(d->misc1 && misc<=0 && clk3==28)
12176
5/6
✓ Branch 0 taken 932879 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 620599 times.
✓ Branch 3 taken 312280 times.
✓ Branch 4 taken 599052 times.
✓ Branch 5 taken 21547 times.
932879 if(dmisc1 && misc<=0 && clk3==28)
12177 {
12178
2/2
✓ Branch 0 taken 16835 times.
✓ Branch 1 taken 4712 times.
21547 if(dmisc2 != 1)
12179 {
12180
2/2
✓ Branch 0 taken 14907 times.
✓ Branch 1 taken 1928 times.
16835 if(lined_up(8,false) == dir)
12181 {
12182 // addEwpn(x,y,z,wpn,0,wdp,dir,getUID());
12183 // sfx(WAV_WAND,pan(x));
12184 1928 wizzrobe_attack_for_real();
12185 1928 fclk=30;
12186 1928 }
12187 16835 }
12188 else
12189 {
12190
2/2
✓ Branch 0 taken 3717 times.
✓ Branch 1 taken 995 times.
4712 if((zc_oldrand()%500)>=400)
12191 {
12192 995 wizzrobe_attack_for_real();
12193 995 fclk=30;
12194 995 }
12195 }
12196 21547 }
12197
12198
4/4
✓ Branch 0 taken 517526 times.
✓ Branch 1 taken 415353 times.
✓ Branch 2 taken 4050 times.
✓ Branch 3 taken 513476 times.
932879 if(misc==0 && (zc_oldrand()&127)==0)
12199 4050 misc=2;
12200
12201
4/4
✓ Branch 0 taken 67953 times.
✓ Branch 1 taken 864926 times.
✓ Branch 2 taken 64512 times.
✓ Branch 3 taken 3441 times.
932879 if(misc==2 && clk3==4)
12202 3441 fix_coords();
12203
12204
2/4
✓ Branch 0 taken 932879 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 932879 times.
932879 if(!(charging||firing)) //should never be charging or firing for these wizzrobes
12205 {
12206
2/2
✓ Branch 0 taken 849597 times.
✓ Branch 1 taken 83282 times.
932879 if(fclk>0)
12207 {
12208 83282 --fclk;
12209 83282 }
12210 932879 }
12211
12212 1019220 }
12213
12214 21531 void eWizzrobe::wizzrobe_newdir(int32_t homing)
12215 {
12216 // Wizzrobes shouldn't move to the edge of the screen;
12217 // if they're already there, they should move toward the center
12218
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 21498 times.
21531 if(x<32)
12219 33 dir=right;
12220
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 21494 times.
21498 else if(x>=world_w-32)
12221 4 dir=left;
12222
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 21492 times.
21494 else if(y<32)
12223 2 dir=down;
12224
2/2
✓ Branch 0 taken 21487 times.
✓ Branch 1 taken 5 times.
21492 else if(y>=world_h-32)
12225 5 dir=up;
12226 else
12227 21487 newdir(4,homing,spw_wizzrobe);
12228 21531 }
12229
12230 2099229 void eWizzrobe::draw(BITMAP *dest)
12231 {
12232 // if(d->misc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk) // phasing
12233
13/14
✓ Branch 0 taken 1042483 times.
✓ Branch 1 taken 1056746 times.
✓ Branch 2 taken 817873 times.
✓ Branch 3 taken 224610 times.
✓ Branch 4 taken 132112 times.
✓ Branch 5 taken 910371 times.
✓ Branch 6 taken 130752 times.
✓ Branch 7 taken 1360 times.
✓ Branch 8 taken 129926 times.
✓ Branch 9 taken 826 times.
✓ Branch 10 taken 125018 times.
✓ Branch 11 taken 4908 times.
✓ Branch 12 taken 125018 times.
✗ Branch 13 not taken.
2099229 if(dmisc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk && !frozenclock) // phasing
12234 125018 return;
12235
12236 1974211 int32_t tempint=dummy_int[1];
12237 1974211 bool tempbool1=dummy_bool[1];
12238 1974211 bool tempbool2=dummy_bool[2];
12239 1974211 dummy_int[1]=fclk;
12240 1974211 dummy_bool[1]=charging;
12241 1974211 dummy_bool[2]=firing;
12242 1974211 update_enemy_frame();
12243 1974211 dummy_int[1]=tempint;
12244 1974211 dummy_bool[1]=tempbool1;
12245 1974211 dummy_bool[2]=tempbool2;
12246 1974211 enemy::draw(dest);
12247 2099229 }
12248
12249 203 eDodongo::eDodongo(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12250 203 {
12251 203 fading=fade_flash_die;
12252
6/8
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 154 times.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 49 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 46 times.
203 if(dir==down&&y>=128)
12253 {
12254 3 dir=up;
12255 3 }
12256
12257
5/8
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 141 times.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 62 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 62 times.
203 if(dir==right&&x>=208)
12258 {
12259 dir=left;
12260 }
12261
1/4
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
203 if (SIZEflags != 0) init_size_flags();;
12262 203 }
12263
12264 125855 bool eDodongo::animate(int32_t index)
12265 {
12266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125855 times.
125855 if(switch_hooked) return enemy::animate(index);
12267
2/2
✓ Branch 0 taken 3790 times.
✓ Branch 1 taken 122065 times.
125855 if(dying)
12268 {
12269 3790 return Dead(index);
12270 }
12271
12272
2/2
✓ Branch 0 taken 121496 times.
✓ Branch 1 taken 569 times.
122065 if(clk==0)
12273 {
12274 569 removearmos(x,y);
12275 569 }
12276
12277
2/2
✓ Branch 0 taken 10848 times.
✓ Branch 1 taken 111217 times.
122065 if(clk2) // ate a bomb
12278 {
12279
2/2
✓ Branch 0 taken 10735 times.
✓ Branch 1 taken 113 times.
10848 if(--clk2==0)
12280 113 hp-=misc; // store bomb's power in misc
12281 10848 }
12282 else
12283 111217 constant_walk(rate,homing,spw_clipright);
12284
12285 122065 hit_width = (dir<=down) ? 16 : 32;
12286 // hysz = (dir>=left) ? 16 : 32;
12287
12288 122065 return enemy::animate(index);
12289 125855 }
12290
12291 125845 void eDodongo::draw(BITMAP *dest)
12292 {
12293 125845 tile=o_tile;
12294
12295
2/2
✓ Branch 0 taken 3065 times.
✓ Branch 1 taken 122780 times.
125845 if(clk<0)
12296 {
12297 3065 enemy::drawzcboss(dest);
12298 3065 return;
12299 }
12300
12301 122780 update_enemy_frame();
12302 122780 enemy::drawzcboss(dest);
12303
12304
2/2
✓ Branch 0 taken 51662 times.
✓ Branch 1 taken 71118 times.
122780 if(dummy_int[1]!=0) //additional tiles
12305 {
12306 71118 tile+=dummy_int[1]; //second tile is previous tile
12307 71118 xofs-=16; //new xofs change
12308 71118 enemy::drawzcboss(dest);
12309 71118 xofs+=16;
12310 71118 }
12311
12312 125845 }
12313
12314 8218 int32_t eDodongo::takehit(weapon *w, weapon* realweap)
12315 {
12316 8218 int32_t wpnId = w->id;
12317 8218 int32_t power = w->power;
12318 8218 int32_t wpnx = w->x;
12319 8218 int32_t wpny = w->y;
12320
12321
5/12
✓ Branch 0 taken 8218 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8218 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2457 times.
✓ Branch 5 taken 5761 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2457 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
8218 if(dying || clk<0 || clk2>0 || (superman && !(superman>1 && wpnId==wSBomb)))
12322 5761 return 0;
12323
12324
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 803 times.
✓ Branch 2 taken 1491 times.
✓ Branch 3 taken 17 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 146 times.
2457 switch(wpnId)
12325 {
12326 case wPhantom:
12327 return 0;
12328
12329 case wFire:
12330 case wBait:
12331 case wWhistle:
12332 case wWind:
12333 case wSSparkle:
12334 case wFSparkle:
12335 return 0;
12336
12337 case wLitBomb:
12338 case wLitSBomb:
12339
6/6
✓ Branch 0 taken 266 times.
✓ Branch 1 taken 537 times.
✓ Branch 2 taken 293 times.
✓ Branch 3 taken 510 times.
✓ Branch 4 taken 690 times.
✓ Branch 5 taken 113 times.
803 if(abs(wpnx-((dir==right)?x+16:x)) > 7 || abs(wpny-y) > 7)
12340 690 return 0;
12341
12342 113 clk2=96;
12343 113 misc=power;
12344
12345
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 3 times.
113 if(wpnId==wLitSBomb)
12346 3 item_set=isSBOMB100;
12347
12348 113 return 1;
12349
12350 case wBomb:
12351 case wSBomb:
12352
6/6
✓ Branch 0 taken 427 times.
✓ Branch 1 taken 1064 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 1071 times.
✓ Branch 4 taken 516 times.
✓ Branch 5 taken 975 times.
1491 if(abs(wpnx-((dir==right)?x+16:x)) > 8 || abs(wpny-y) > 8)
12353 516 return 0;
12354
12355 975 stunclk=160;
12356 975 misc=wpnId; // store wpnId
12357 975 return 1;
12358
12359 case wSword:
12360
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 88 times.
146 if(stunclk)
12361 {
12362 88 sfx(WAV_EHIT,pan(x));
12363 88 hp=0;
12364 88 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12365 88 fading=0; // don't flash
12366 88 return 1;
12367 }
12368
12369 [[fallthrough]];
12370 default:
12371 75 sfx(WAV_CHINK,pan(x));
12372 75 }
12373
12374 75 return 1;
12375 8218 }
12376
12377 48 eDodongo2::eDodongo2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12378 48 {
12379 48 fading=fade_flash_die;
12380 //nets+5180;
12381 48 previous_dir=-1;
12382
6/8
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 13 times.
48 if(dir==down&&y>=128)
12383 {
12384 1 dir=up;
12385 1 }
12386
12387
5/8
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 12 times.
48 if(dir==right&&x>=208)
12388 {
12389 dir=left;
12390 }
12391
1/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if (SIZEflags != 0) init_size_flags();;
12392 48 }
12393
12394 39398 bool eDodongo2::animate(int32_t index)
12395 {
12396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39398 times.
39398 if(switch_hooked) return enemy::animate(index);
12397
2/2
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 38240 times.
39398 if(dying)
12398 {
12399 1158 return Dead(index);
12400 }
12401
12402
2/2
✓ Branch 0 taken 38073 times.
✓ Branch 1 taken 167 times.
38240 if(clk==0)
12403 {
12404 167 removearmos(x,y);
12405 167 }
12406
12407
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 34208 times.
38240 if(clk2) // ate a bomb
12408 {
12409
2/2
✓ Branch 0 taken 3990 times.
✓ Branch 1 taken 42 times.
4032 if(--clk2==0)
12410 42 hp-=misc; // store bomb's power in misc
12411 4032 }
12412 else
12413 34208 constant_walk(rate,homing,spw_clipbottomright);
12414
12415 38240 hit_width = (dir<=down) ? 16 : 32;
12416 38240 hit_height = (dir>=left) ? 16 : 32;
12417 38240 hxofs=(dir>=left)?-8:0;
12418 38240 hyofs=(dir<left)?-8:0;
12419
12420 38240 return enemy::animate(index);
12421 39398 }
12422
12423 39601 void eDodongo2::draw(BITMAP *dest)
12424 {
12425
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 38833 times.
39601 if(clk<0)
12426 {
12427 768 enemy::drawzcboss(dest);
12428 768 return;
12429 }
12430
12431 38833 int32_t tempx=xofs;
12432 38833 int32_t tempy=yofs;
12433 38833 update_enemy_frame();
12434 38833 enemy::drawzcboss(dest);
12435 38833 tile+=dummy_int[1]; //second tile change
12436 38833 xofs+=dummy_int[2]; //new xofs change
12437 38833 yofs+=dummy_int[3]; //new yofs change
12438 38833 enemy::drawzcboss(dest);
12439 38833 xofs=tempx;
12440 38833 yofs=tempy;
12441 39601 }
12442
12443 3929 int32_t eDodongo2::takehit(weapon *w, weapon* realweap)
12444 {
12445 3929 int32_t wpnId = w->id;
12446 3929 int32_t power = w->power;
12447 3929 int32_t wpnx = w->x;
12448 3929 int32_t wpny = w->y;
12449
12450
5/8
✓ Branch 0 taken 3929 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3929 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1552 times.
✓ Branch 5 taken 2377 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1552 times.
3929 if(dying || clk<0 || clk2>0 || superman)
12451 2377 return 0;
12452
12453
5/6
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 321 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 31 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 161 times.
1552 switch(wpnId)
12454 {
12455 case wPhantom:
12456 return 0;
12457
12458 case wFire:
12459 case wBait:
12460 case wWhistle:
12461 case wWind:
12462 case wSSparkle:
12463 case wFSparkle:
12464 346 return 0;
12465
12466 case wLitBomb:
12467 case wLitSBomb:
12468
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 81 times.
321 switch(dir)
12469 {
12470 case up:
12471
4/4
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 4 times.
81 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12472 77 return 0;
12473
12474 4 break;
12475
12476 case down:
12477
4/4
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 6 times.
77 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12478 71 return 0;
12479
12480 6 break;
12481
12482 case left:
12483
4/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 16 times.
82 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12484 66 return 0;
12485
12486 16 break;
12487
12488 case right:
12489
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 65 times.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 16 times.
81 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12490 65 return 0;
12491
12492 16 break;
12493 }
12494
12495 // if(abs(wpnx-((dir==right)?x+8:(dir==left)?x-8:0)) > 7 || abs(wpny-((dir==down)?y+8:(dir==up)?y-8:0)) > 7)
12496 // return 0;
12497 42 clk2=96;
12498 42 misc=power;
12499
12500
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(wpnId==wLitSBomb)
12501 item_set=isSBOMB100;
12502
12503 42 return 1;
12504
12505 case wBomb:
12506 case wSBomb:
12507
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 176 times.
✓ Branch 2 taken 168 times.
✓ Branch 3 taken 185 times.
✓ Branch 4 taken 164 times.
693 switch(dir)
12508 {
12509 case up:
12510
4/4
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 84 times.
✓ Branch 3 taken 92 times.
176 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12511 84 return 0;
12512
12513 92 break;
12514
12515 case down:
12516
4/4
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 87 times.
✓ Branch 2 taken 113 times.
✓ Branch 3 taken 55 times.
168 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12517 113 return 0;
12518
12519 55 break;
12520
12521 case left:
12522
4/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 80 times.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 105 times.
185 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12523 80 return 0;
12524
12525 105 break;
12526
12527 case right:
12528
4/4
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 67 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 93 times.
164 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12529 71 return 0;
12530
12531 93 break;
12532 }
12533
12534 345 stunclk=160;
12535 345 misc=wpnId; // store wpnId
12536 345 return 1;
12537
12538 case wSword:
12539
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 34 times.
161 if(stunclk)
12540 {
12541 34 sfx(WAV_EHIT,pan(x));
12542 34 hp=0;
12543 34 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12544 34 fading=0; // don't flash
12545 34 return 1;
12546 }
12547
12548 [[fallthrough]];
12549 default:
12550 158 sfx(WAV_CHINK,pan(x));
12551 158 }
12552
12553 158 return 1;
12554 3929 }
12555
12556 126 eAquamentus::eAquamentus(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)//enemy((zfix)176,(zfix)64,Id,Clk)
12557 126 {
12558 //these are here to bypass compiler warnings about unused arguments
12559
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if ( !(editorflags & ENEMY_FLAG5) )
12560 {
12561
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 position_relative_to_screen(x, y, dmisc1 ? 64 : 176, 64);
12562 126 }
12563 else { x = X; y = Y; }
12564
12565 //nets+5940;
12566
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 45 times.
126 if(get_qr(qr_NEWENEMYTILES))
12567 {
12568 81 }
12569 else
12570 {
12571
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 7 times.
45 if(dmisc1)
12572 {
12573 7 flip=1;
12574 7 }
12575 }
12576
12577
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
12578 126 clk3=32;
12579 126 clk2=0;
12580 126 clk4=clk;
12581 126 dir=left;
12582
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
126 if (SIZEflags != 0) init_size_flags();;
12583 126 }
12584
12585 71899 bool eAquamentus::animate(int32_t index)
12586 {
12587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71899 times.
71899 if(switch_hooked) return enemy::animate(index);
12588
2/2
✓ Branch 0 taken 2092 times.
✓ Branch 1 taken 69807 times.
71899 if(dying)
12589 2092 return Dead(index);
12590
12591 // fbx=x+((id==eRAQUAM)?4:-4);
12592
2/2
✓ Branch 0 taken 69490 times.
✓ Branch 1 taken 317 times.
69807 if(clk==0)
12593 {
12594 317 removearmos(x,y);
12595 317 }
12596
12597 69807 fbx=x;
12598
12599 /*
12600 if (get_qr(qr_NEWENEMYTILES)&&id==eLAQUAM)
12601 {
12602 fbx+=16;
12603 }
12604 */
12605
2/2
✓ Branch 0 taken 69357 times.
✓ Branch 1 taken 450 times.
69807 if(--clk3==0)
12606 {
12607 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,up+1);
12608 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,0);
12609 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,down+1);
12610 450 addEwpn(fbx,y,z,wpn,2,wdp,up,getUID(), 0, fakez);
12611 450 addEwpn(fbx,y,z,wpn,2,wdp,8,getUID(), 0, fakez);
12612 450 addEwpn(fbx,y,z,wpn,2,wdp,down,getUID(), 0, fakez);
12613 450 sfx(wpnsfx(wpn),pan(x));
12614 450 }
12615
12616
4/4
✓ Branch 0 taken 21363 times.
✓ Branch 1 taken 48444 times.
✓ Branch 2 taken 21018 times.
✓ Branch 3 taken 345 times.
69807 if(clk3<-80 && !(zc_oldrand()&63))
12617 {
12618 345 clk3=32;
12619 345 }
12620
12621 69807 int screen_x = x.getInt()%256;
12622
2/2
✓ Branch 0 taken 68690 times.
✓ Branch 1 taken 1117 times.
69807 if(!((clk4+1)&63))
12623 {
12624 1117 int32_t d2=(zc_oldrand()%3)+1;
12625
12626
2/2
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 752 times.
1117 if(d2>=left)
12627 {
12628 752 dir=d2;
12629 752 }
12630
12631
2/2
✓ Branch 0 taken 732 times.
✓ Branch 1 taken 385 times.
1117 if(dmisc1)
12632 {
12633
2/2
✓ Branch 0 taken 347 times.
✓ Branch 1 taken 38 times.
385 if(screen_x<=40)
12634 {
12635 38 dir=right;
12636 38 }
12637
12638
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 if(screen_x>=104)
12639 {
12640 dir=left;
12641 }
12642 385 }
12643 else
12644 {
12645
2/2
✓ Branch 0 taken 711 times.
✓ Branch 1 taken 21 times.
732 if(screen_x<=136)
12646 {
12647 21 dir=right;
12648 21 }
12649
12650
2/2
✓ Branch 0 taken 698 times.
✓ Branch 1 taken 34 times.
732 if(screen_x>=200)
12651 {
12652 34 dir=left;
12653 34 }
12654 }
12655 1117 }
12656
12657
4/4
✓ Branch 0 taken 67907 times.
✓ Branch 1 taken 1900 times.
✓ Branch 2 taken 59366 times.
✓ Branch 3 taken 8541 times.
69807 if(clk4>=-1 && !((clk4+1)&7))
12658 {
12659
2/2
✓ Branch 0 taken 4546 times.
✓ Branch 1 taken 3995 times.
8541 if(dir==left)
12660 {
12661 4546 x-=1;
12662 4546 }
12663 else
12664 {
12665 3995 x+=1;
12666 }
12667 8541 }
12668
12669 69807 clk4=(clk4+1)%256;
12670
12671 69807 return enemy::animate(index);
12672 71899 }
12673
12674 72310 void eAquamentus::draw(BITMAP *dest)
12675 {
12676
2/2
✓ Branch 0 taken 44994 times.
✓ Branch 1 taken 27316 times.
72310 if(get_qr(qr_NEWENEMYTILES))
12677 {
12678 44994 xofs=(dmisc1?-16:0);
12679
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44994 times.
✓ Branch 2 taken 18341 times.
✓ Branch 3 taken 26653 times.
44994 if ( do_animation ) tile=o_tile+((clk&24)>>2)+(clk3>-32?(clk3>0?40:80):0);
12680
12681
2/2
✓ Branch 0 taken 1312 times.
✓ Branch 1 taken 43682 times.
44994 if(dying)
12682 {
12683 1312 xofs=0;
12684 1312 enemy::draw(dest);
12685 1312 }
12686 else
12687 {
12688 43682 drawblock(dest,15);
12689 }
12690 44994 }
12691 else
12692 {
12693 27316 int32_t xblockofs=((dmisc1)?-16:16);
12694 27316 xofs=0;
12695
12696
4/4
✓ Branch 0 taken 26634 times.
✓ Branch 1 taken 682 times.
✓ Branch 2 taken 780 times.
✓ Branch 3 taken 25854 times.
27316 if(clk<0 || dying)
12697 {
12698 1462 enemy::draw(dest);
12699 1462 return;
12700 }
12701
1/2
✓ Branch 0 taken 25854 times.
✗ Branch 1 not taken.
25854 if ( do_animation )
12702 {
12703 // face (0=firing, 2=resting)
12704 25854 tile=o_tile+((clk3>0)?0:2);
12705 25854 enemy::draw(dest);
12706 // tail (
12707 25854 tile=o_tile+((clk&16)?1:3);
12708 25854 xofs=xblockofs;
12709 25854 enemy::draw(dest);
12710 // body
12711 25854 yofs+=16;
12712 25854 xofs=0;
12713 25854 tile=o_tile+((clk&16)?20:22);
12714 25854 enemy::draw(dest);
12715 25854 xofs=xblockofs;
12716 25854 tile=o_tile+((clk&16)?21:23);
12717 25854 enemy::draw(dest);
12718 25854 yofs-=16;
12719 25854 }
12720 else enemy::draw(dest);
12721 }
12722 72310 }
12723
12724 23834 bool eAquamentus::hit(weapon *w)
12725 {
12726
3/6
✓ Branch 0 taken 23834 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23834 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23834 times.
23834 if(!w->scriptcoldet || w->fallclk || w->drownclk) return false;
12727
12728
2/2
✓ Branch 0 taken 4201 times.
✓ Branch 1 taken 19633 times.
23834 switch(w->id)
12729 {
12730 case wBeam:
12731 case wRefBeam:
12732 case wMagic:
12733 4201 hit_height=32;
12734 4201 }
12735
12736
4/4
✓ Branch 0 taken 22740 times.
✓ Branch 1 taken 1094 times.
✓ Branch 2 taken 17546 times.
✓ Branch 3 taken 5194 times.
23834 bool ret = (dying || hclk>0) ? false : sprite::hit(w);
12737 23834 hit_height=16;
12738 23834 return ret;
12739
12740 23834 }
12741
12742 93 eGohma::eGohma(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) // enemy((zfix)128,(zfix)48,Id,0)
12743 93 {
12744
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if ( !(editorflags & ENEMY_FLAG5) )
12745 {
12746
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 position_relative_to_screen(x, y, 128, 48);
12747 93 }
12748 else { x = X; y = Y; }
12749
12750 93 Clk=Clk;
12751
2/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
93 if(flags & guy_fade_flicker)
12752 {
12753 clk=0;
12754 superman = 1;
12755 fading=fade_flicker;
12756 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
12757 }
12758
3/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 42 times.
93 else if(flags & guy_fade_instant)
12759 {
12760 42 clk=0;
12761 42 }
12762 93 hxofs=-16;
12763 93 hit_width=48;
12764 93 clk4=0;
12765
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
93 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
12766
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 dir=zc_oldrand()%3+1;
12767
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
93 if (SIZEflags != 0) init_size_flags();;
12768
12769 //nets+5340;
12770 93 }
12771
12772 70891 bool eGohma::animate(int32_t index)
12773 {
12774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70891 times.
70891 if(switch_hooked) return enemy::animate(index);
12775
2/2
✓ Branch 0 taken 1226 times.
✓ Branch 1 taken 69665 times.
70891 if(dying)
12776 1226 return Dead(index);
12777
12778
2/2
✓ Branch 0 taken 69629 times.
✓ Branch 1 taken 36 times.
69665 if(fading)
12779 {
12780
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 1 times.
36 if(++clk4 > 60)
12781 {
12782 35 clk4=0;
12783 35 superman=0;
12784 35 fading=0;
12785 35 clk=0;
12786
12787 35 }
12788 1 else return enemy::animate(index);
12789 35 }
12790
12791
2/2
✓ Branch 0 taken 69314 times.
✓ Branch 1 taken 350 times.
69664 if(clk==0)
12792 {
12793
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
350 if (activated_handle && !activated_handle->is_rpos()) removearmos(x,y);
12794 else
12795 {
12796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
350 removearmos(zc_max(x-16, 0_zf),y);
12797 350 did_armos = false;
12798 350 removearmos(x,y);
12799 350 did_armos = false;
12800
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 removearmos(zc_min(x+16, 255_zf),y);
12801 }
12802 350 }
12803
12804
2/2
✓ Branch 0 taken 68878 times.
✓ Branch 1 taken 786 times.
69664 if(clk<0) return enemy::animate(index);
12805
12806 // Movement clk must be separate from animation clk because of the Clock item
12807
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68878 times.
68878 if(!watch)
12808 68878 clk4++;
12809
12810
2/2
✓ Branch 0 taken 67846 times.
✓ Branch 1 taken 1032 times.
68878 if((clk4&63)==0)
12811 {
12812
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 486 times.
1032 if(clk4&64)
12813 546 dir^=1;
12814 else
12815 486 dir=zc_oldrand()%3+1;
12816 1032 }
12817
12818
2/2
✓ Branch 0 taken 67761 times.
✓ Branch 1 taken 1117 times.
68878 if((clk&63)==3)
12819 {
12820
2/2
✓ Branch 0 taken 882 times.
✓ Branch 1 taken 235 times.
1117 switch(dmisc1)
12821 {
12822 case 1:
12823 235 addEwpn(x,y+2,z,wpn,3,wdp,left,getUID(), 0, fakez);
12824 235 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
12825 235 addEwpn(x,y+2,z,wpn,3,wdp,right,getUID(), 0, fakez);
12826 235 sfx(wpnsfx(wpn),pan(x));
12827 235 break;
12828
12829 default:
12830
3/4
✓ Branch 0 taken 882 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 754 times.
882 if(dmisc1 != 1 && dmisc1 != 2)
12831 {
12832 754 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
12833 754 sfx(wpnsfx(wpn),pan(x));
12834 754 sfx(wpnsfx(wpn),pan(x));
12835 754 }
12836
12837 882 break;
12838 }
12839 1117 }
12840
12841
6/6
✓ Branch 0 taken 8027 times.
✓ Branch 1 taken 60851 times.
✓ Branch 2 taken 7611 times.
✓ Branch 3 taken 416 times.
✓ Branch 4 taken 5396 times.
✓ Branch 5 taken 2215 times.
68878 if((dmisc1 == 2)&& clk3>=16 && clk3<116)
12842 {
12843
2/2
✓ Branch 0 taken 290 times.
✓ Branch 1 taken 1925 times.
2215 if(!(clk3%8))
12844 {
12845 290 FireBreath(true);
12846 290 }
12847 2215 }
12848
12849
2/2
✓ Branch 0 taken 34399 times.
✓ Branch 1 taken 34479 times.
68878 if(clk4&1)
12850 34479 move((zfix)1);
12851
12852
2/2
✓ Branch 0 taken 68728 times.
✓ Branch 1 taken 150 times.
68878 if(++clk3>=400)
12853 150 clk3=0;
12854
12855 68878 return enemy::animate(index);
12856 70891 }
12857
12858 70889 void eGohma::draw(BITMAP *dest)
12859 {
12860 70889 tile=o_tile;
12861
12862
4/4
✓ Branch 0 taken 70103 times.
✓ Branch 1 taken 786 times.
✓ Branch 2 taken 1226 times.
✓ Branch 3 taken 68877 times.
70889 if(clk<0 || dying)
12863 {
12864 2012 enemy::drawzcboss(dest);
12865 2012 return;
12866 }
12867
12868
2/2
✓ Branch 0 taken 53472 times.
✓ Branch 1 taken 15405 times.
68877 if(get_qr(qr_NEWENEMYTILES))
12869 {
12870 ///if ( do_animation )
12871 //Yuck. Gohma can just not have this capability right now.
12872 // left side
12873 53472 xofs=-16;
12874 53472 flip=0;
12875 // if(clk&16) tile=180;
12876 // else { tile=182; flip=1; }
12877 53472 tile+=(3*((clk&48)>>4));
12878 53472 enemy::drawzcboss(dest);
12879
12880 // right side
12881 53472 xofs=16;
12882 // tile=(180+182)-tile;
12883 53472 tile=o_tile;
12884 53472 tile+=(3*((clk&48)>>4))+2;
12885 53472 enemy::drawzcboss(dest);
12886
12887 // body
12888 53472 xofs=0; //Gohma may need more adjustments for SIZEflags. -Z 14 Aug 2020
12889 53472 tile=o_tile;
12890
12891 // tile+=(3*((clk&24)>>3))+2;
12892
2/2
✓ Branch 0 taken 2975 times.
✓ Branch 1 taken 50497 times.
53472 if(clk3<16)
12893 2975 tile+=7;
12894
2/2
✓ Branch 0 taken 15890 times.
✓ Branch 1 taken 34607 times.
50497 else if(clk3<116)
12895 15890 tile+=10;
12896
2/2
✓ Branch 0 taken 2051 times.
✓ Branch 1 taken 32556 times.
34607 else if(clk3<132)
12897 2051 tile+=7;
12898 else
12899 32556 tile+=((clk3-132)&24)?4:1;
12900
12901 53472 enemy::drawzcboss(dest);
12902
12903 53472 }
12904 else
12905 {
12906 // left side
12907 15405 xofs=-16;
12908 15405 flip=0;
12909
12910
2/2
✓ Branch 0 taken 7615 times.
✓ Branch 1 taken 7790 times.
15405 if(!(clk&16))
12911 {
12912 7790 tile+=2;
12913 7790 flip=1;
12914 7790 }
12915
12916 15405 enemy::draw(dest);
12917
12918 // right side
12919 15405 tile=o_tile;
12920 15405 xofs=16;
12921
12922
2/2
✓ Branch 0 taken 7790 times.
✓ Branch 1 taken 7615 times.
15405 if((clk&16)) tile+=2;
12923
12924 // tile=(180+182)-tile;
12925 15405 enemy::draw(dest);
12926
12927 // body
12928 15405 tile=o_tile;
12929 15405 xofs=0;
12930
12931
2/2
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 14493 times.
15405 if(clk3<16)
12932 912 tile+=4;
12933
2/2
✓ Branch 0 taken 4882 times.
✓ Branch 1 taken 9611 times.
14493 else if(clk3<116)
12934 4882 tile+=5;
12935
2/2
✓ Branch 0 taken 585 times.
✓ Branch 1 taken 9026 times.
9611 else if(clk3<132)
12936 585 tile+=4;
12937 9026 else tile+=((clk3-132)&8)?3:1;
12938
12939 15405 enemy::draw(dest);
12940
12941 }
12942 70889 }
12943
12944 578 int32_t eGohma::takehit(weapon *w, weapon* realweap)
12945 {
12946 578 int32_t wpnId = w->id;
12947 578 int32_t power = w->power;
12948 578 int32_t wpnx = w->x;
12949 578 int32_t wpnDir = w->dir;
12950 578 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
12951
12952
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 421 times.
578 if(def < 0)
12953 {
12954
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 421 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 367 times.
✓ Branch 5 taken 54 times.
✓ Branch 6 taken 364 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 328 times.
✓ Branch 9 taken 36 times.
421 if(!((wpnDir==up || wpnDir==l_up || wpnDir==r_up) && abs(int32_t(x)-wpnx)<=8 && clk3>=16 && clk3<116))
12955 {
12956 93 sfx(WAV_CHINK,pan(x));
12957 93 return 1;
12958 }
12959 328 }
12960
12961 485 return enemy::takehit(w, realweap);
12962 578 }
12963
12964 327 eLilDig::eLilDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12965 327 {
12966 327 count_enemy=(id==(id&0xFFF));
12967 //nets+4360+(((id&0xFF)-eDIGPUP2)*40);
12968
1/4
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
327 if (SIZEflags != 0) init_size_flags();;
12969 327 }
12970
12971 124050 bool eLilDig::animate(int32_t index)
12972 {
12973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124050 times.
124050 if(switch_hooked) return enemy::animate(index);
12974
2/2
✓ Branch 0 taken 4410 times.
✓ Branch 1 taken 119640 times.
124050 if(dying)
12975 4410 return Dead(index);
12976
12977
2/2
✓ Branch 0 taken 7105 times.
✓ Branch 1 taken 112535 times.
119640 if(clk==0)
12978 {
12979 7105 removearmos(x,y);
12980 7105 }
12981
12982
2/2
✓ Branch 0 taken 80994 times.
✓ Branch 1 taken 38646 times.
119640 if(misc<=128)
12983 {
12984
2/2
✓ Branch 0 taken 1161 times.
✓ Branch 1 taken 37485 times.
38646 if(!(++misc&31))
12985 1161 step+=0.25;
12986 38646 }
12987
12988 119640 variable_walk_8(rate,homing,hrate,spw_floater);
12989 119640 return enemy::animate(index);
12990 124050 }
12991
12992 124268 void eLilDig::draw(BITMAP *dest)
12993 {
12994 124268 tile = o_tile;
12995 // tile = 160;
12996 124268 int32_t fdiv = frate/4;
12997
1/2
✓ Branch 0 taken 124268 times.
✗ Branch 1 not taken.
124268 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
12998
2/2
✓ Branch 0 taken 91457 times.
✓ Branch 1 taken 32811 times.
124268 int32_t f2=get_qr(qr_NEWENEMYTILES)?
12999 124268 efrate:((clk>=(frate>>1))?1:0);
13000
13001
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124268 times.
124268 if ( do_animation )
13002 {
13003
2/2
✓ Branch 0 taken 91457 times.
✓ Branch 1 taken 32811 times.
124268 if(get_qr(qr_NEWENEMYTILES))
13004 {
13005
9/9
✓ Branch 0 taken 11370 times.
✓ Branch 1 taken 10699 times.
✓ Branch 2 taken 10722 times.
✓ Branch 3 taken 12015 times.
✓ Branch 4 taken 10070 times.
✓ Branch 5 taken 9554 times.
✓ Branch 6 taken 8255 times.
✓ Branch 7 taken 10033 times.
✓ Branch 8 taken 8739 times.
91457 switch(dir-8) //directions get screwed up after 8. *shrug*
13006 {
13007 case up: //u
13008 11370 flip=0;
13009 11370 break;
13010
13011 case l_up: //d
13012 10699 flip=0;
13013 10699 tile+=4;
13014 10699 break;
13015
13016 case l_down: //l
13017 10722 flip=0;
13018 10722 tile+=8;
13019 10722 break;
13020
13021 case left: //r
13022 12015 flip=0;
13023 12015 tile+=12;
13024 12015 break;
13025
13026 case r_down: //ul
13027 10070 flip=0;
13028 10070 tile+=20;
13029 10070 break;
13030
13031 case down: //ur
13032 9554 flip=0;
13033 9554 tile+=24;
13034 9554 break;
13035
13036 case r_up: //dl
13037 8255 flip=0;
13038 8255 tile+=28;
13039 8255 break;
13040
13041 case right: //dr
13042 10033 flip=0;
13043 10033 tile+=32;
13044 10033 break;
13045 }
13046
13047 91457 tile+=f2;
13048 91457 }
13049 else
13050 {
13051 32811 tile+=(clk>=6)?1:0;
13052 }
13053 124268 }
13054
13055 124268 enemy::draw(dest);
13056 124268 }
13057
13058 80 eBigDig::eBigDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13059 80 {
13060
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 init_size_flags();
13061 80 }
13062
13063 29662 bool eBigDig::animate(int32_t index)
13064 {
13065
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29662 times.
29662 if(switch_hooked) return enemy::animate(index);
13066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29662 times.
29662 if(dying)
13067 return Dead(index);
13068
13069
2/2
✓ Branch 0 taken 25558 times.
✓ Branch 1 taken 4104 times.
29662 if(clk==0)
13070 {
13071 4104 removearmos(x,y);
13072 4104 }
13073
13074
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29534 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 64 times.
29662 switch(misc)
13075 {
13076 case 0:
13077 29534 variable_walk_8(rate,homing,hrate,spw_floater,-8,-16,23,23);
13078 29534 break;
13079
13080 case 1:
13081 64 ++misc;
13082 64 break;
13083
13084 case 2:
13085
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 64 times.
175 for(int32_t i=0; i<dmisc5; i++)
13086 {
13087 111 addenemy(screen_spawned,x,y,dmisc1+0x1000,-15);
13088 111 }
13089
13090
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc6; i++)
13091 {
13092 30 addenemy(screen_spawned,x,y,dmisc2+0x1000,-15);
13093 30 }
13094
13095
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc7; i++)
13096 {
13097 30 addenemy(screen_spawned,x,y,dmisc3+0x1000,-15);
13098 30 }
13099
13100
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc8; i++)
13101 {
13102 30 addenemy(screen_spawned,x,y,dmisc4+0x1000,-15);
13103 30 }
13104
13105
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2 times.
64 if(itemguy) // Hand down the carried item
13106 {
13107 2 int guycarryingitem = guys.Count()-1;
13108 2 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
13109 2 itemguy = false;
13110 2 }
13111
13112 64 stop_bgsfx(index);
13113
13114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(deadsfx > 0) sfx(deadsfx,pan(x));
13115
13116 64 return true;
13117 }
13118
13119 29598 return enemy::animate(index);
13120 29662 }
13121
13122 29658 void eBigDig::draw(BITMAP *dest)
13123 {
13124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29658 times.
29658 if(anim!=aDIG)
13125 {
13126 update_enemy_frame();
13127 xofs-=8;
13128 yofs-=8;
13129 drawblock(dest,15);
13130 xofs+=8;
13131 yofs+=8;
13132 return;
13133 }
13134
13135 29658 tile = o_tile;
13136 29658 int32_t fdiv = frate/4;
13137
1/2
✓ Branch 0 taken 29658 times.
✗ Branch 1 not taken.
29658 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13138
13139
2/2
✓ Branch 0 taken 16161 times.
✓ Branch 1 taken 13497 times.
29658 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13140 29658 efrate:((clk>=(frate>>1))?1:0);
13141
13142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29658 times.
29658 if ( do_animation )
13143 {
13144
2/2
✓ Branch 0 taken 16161 times.
✓ Branch 1 taken 13497 times.
29658 if(get_qr(qr_NEWENEMYTILES))
13145 {
13146
9/9
✓ Branch 0 taken 1688 times.
✓ Branch 1 taken 1684 times.
✓ Branch 2 taken 2031 times.
✓ Branch 3 taken 1910 times.
✓ Branch 4 taken 2041 times.
✓ Branch 5 taken 2043 times.
✓ Branch 6 taken 1514 times.
✓ Branch 7 taken 1009 times.
✓ Branch 8 taken 2241 times.
16161 switch(dir-8) //directions get screwed up after 8. *shrug*
13147 {
13148 case up: //u
13149 1688 flip=0;
13150 1688 break;
13151
13152 case l_up: //d
13153 1684 flip=0;
13154 1684 tile+=8;
13155 1684 break;
13156
13157 case l_down: //l
13158 2031 flip=0;
13159 2031 tile+=40;
13160 2031 break;
13161
13162 case left: //r
13163 1910 flip=0;
13164 1910 tile+=48;
13165 1910 break;
13166
13167 case r_down: //ul
13168 2041 flip=0;
13169 2041 tile+=80;
13170 2041 break;
13171
13172 case down: //ur
13173 2043 flip=0;
13174 2043 tile+=88;
13175
13176 2043 break;
13177
13178 case r_up: //dl
13179 1514 flip=0;
13180 1514 tile+=120;
13181 1514 break;
13182
13183 case right: //dr
13184 2241 flip=0;
13185 2241 tile+=128;
13186 2241 break;
13187 }
13188
13189 16161 tile+=(f2*2);
13190 16161 }
13191 else
13192 {
13193 13497 tile+=(f2)?0:2;
13194 13497 flip=(clk&1)?1:0;
13195 }
13196 29658 }
13197
13198 29658 xofs-=8;
13199 29658 yofs-=8;
13200 29658 drawblock(dest,15);
13201 29658 xofs+=8;
13202 29658 yofs+=8;
13203 29658 }
13204
13205 869 int32_t eBigDig::takehit(weapon *w, weapon* realweap)
13206 {
13207 869 int32_t wpnId = w->id;
13208
13209
3/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 805 times.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
869 if(wpnId==wWhistle && misc==0)
13210 {
13211 64 misc = 1;
13212 64 w->hit_pierce(this, 0, false);
13213 64 }
13214
13215 869 return 0;
13216 }
13217
13218 80 void eBigDig::init_size_flags()
13219 {
13220 80 SIZEflags = d->SIZEflags;
13221
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
80 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13222 // al_trace("Enemy txsz:%i\n", txsz);
13223
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
80 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
13224
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = d->hxsz;
13225 80 else hit_width = 32;
13226
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = d->hysz;
13227 80 else hit_height = 32;
13228
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = d->hzsz;
13229 80 else hzsz = 16; // hard to jump.
13230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
13231 80 else hxofs = -8;
13232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
13233 80 else hyofs = -8;
13234 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13235
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = d->xofs;
13236
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
13237 {
13238 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
13239 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
13240 }
13241
13242
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = d->zofs;
13243 80 }
13244
13245 13 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13246 13 {
13247 13 hxofs=hyofs=8;
13248
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if (editorflags & ENEMY_FLAG3)
13249 {
13250 hxofs = 4;
13251 hyofs = 4;
13252 hit_width = 24;
13253 hit_height = 24;
13254 SIZEflags|=OVERRIDE_HIT_WIDTH;
13255 SIZEflags|=OVERRIDE_HIT_HEIGHT;
13256 }
13257 13 hzsz=16; //can't be jumped.
13258 13 clk2=70;
13259 13 misc=-1;
13260
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 mapscr* scr = get_scr(screen_spawned);
13261
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
13 mainguy=(!getmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (scr->flags9&fBELOWRETURN));
13262 13 }
13263
13264 18254 bool eGanon::animate(int32_t index) //DO NOT ADD a check for do_animation to this version of GANON!! -Z
13265 {
13266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18254 times.
18254 if(dying)
13267
13268 return Dead(index);
13269
13270
2/2
✓ Branch 0 taken 18182 times.
✓ Branch 1 taken 72 times.
18254 if(clk==0)
13271 {
13272 72 removearmos(x,y);
13273 72 }
13274
13275
6/7
✓ Branch 0 taken 3607 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12680 times.
✓ Branch 3 taken 13 times.
✓ Branch 4 taken 984 times.
✓ Branch 5 taken 960 times.
✓ Branch 6 taken 10 times.
18254 switch(misc)
13276 {
13277 case -1:
13278 13 misc=0;
13279 [[fallthrough]];
13280 case 0:
13281
4/4
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 11985 times.
✓ Branch 2 taken 535 times.
✓ Branch 3 taken 173 times.
12693 if(++clk2>72 && !(zc_oldrand()&3))
13282 {
13283 173 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
13284 173 sfx(wpnsfx(wpn),pan(x));
13285 173 clk2=0;
13286 173 }
13287
13288 12693 Stunclk=0;
13289 12693 constant_walk(rate,homing,spw_none);
13290 12693 break;
13291
13292 case 1:
13293 case 2:
13294
2/2
✓ Branch 0 taken 3566 times.
✓ Branch 1 taken 41 times.
3607 if(--Stunclk<=0)
13295 {
13296 41 int32_t r=zc_oldrand();
13297
13298
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 17 times.
41 if(r&1)
13299 {
13300 17 y=96;
13301
13302
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 11 times.
17 if(r&2)
13303 6 x=160;
13304 else
13305 11 x=48;
13306
13307
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 8 times.
17 if(tooclose(x,y,48))
13308 8 x=208-x;
13309
13310 17 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, x, y);
13311 17 }
13312
13313 41 loadpalset(csBOSS,pSprite(d->bosspal));
13314 41 misc=0;
13315 41 }
13316
13317 3607 break;
13318
13319 case 3:
13320 {
13321
2/2
✓ Branch 0 taken 972 times.
✓ Branch 1 taken 12 times.
984 if(hclk>0)
13322 972 break;
13323
13324 12 misc=4;
13325 12 clk=0;
13326 12 hxofs=1000;
13327 12 loadpalset(9,pSprite(spPILE));
13328 12 music_stop();
13329 12 stop_sfx(WAV_ROAR);
13330
13331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(deadsfx>0) sfx(deadsfx,pan(x));
13332
13333 12 sfx(WAV_GANON);
13334 //Ganon's dustpile; fall in sideview. -Z
13335 //item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
13336 //dustpile->miscellaneous[31] = eeGANON;
13337
6/12
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
12 items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
13338 12 item *dustpile = NULL;
13339 //dustpile = (item *)items.spr(items.Count() - 1)->getUID();
13340 12 dustpile = (item *)items.spr(items.Count() - 1);
13341 12 dustpile->linked_parent = eeGANON; //was miscellaneous[31]
13342 12 break;
13343 }
13344
13345 case 4:
13346
2/2
✓ Branch 0 taken 948 times.
✓ Branch 1 taken 12 times.
960 if(clk>=80)
13347 {
13348 12 misc=5;
13349
13350 //game->lvlitems[dlevel]|=(1 << li_boss_killed);
13351
13352 12 sfx(WAV_CLEARED);
13353 //Add the big TF over the ashes!
13354
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 12 times.
36 for(word q = 0; q < items.Count(); q++)
13355 {
13356 24 item *ashes = (item*)items.spr(q);
13357
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 12 times.
24 if ( ashes->linked_parent == eeGANON && (ashes->pickup&ipDUMMY))
13358 {
13359 //Z_scripterrlog("Found correct dustpile!\n");
13360
4/8
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
12 items.add(new item(ashes->x,ashes->y,(zfix)0,iBigTri,ipBIGTRI,0));
13361 12 item *bigtriforce = NULL;
13362 12 bigtriforce = (item *)items.spr(items.Count() - 1);
13363 12 bigtriforce->linked_parent = eeGANON;
13364 12 }
13365 24 }
13366 12 }
13367
13368 960 break;
13369 10 case 5: return true;
13370 }
13371
13372 18244 return enemy::animate(index);
13373 18254 }
13374
13375
13376 964 int32_t eGanon::takehit(weapon *w, weapon* realweap)
13377 {
13378 //these are here to bypass compiler warnings about unused arguments
13379 964 int32_t wpnId = w->id;
13380 964 int32_t power = w->power;
13381 964 int32_t enemyHitWeapon = w->parentitem;
13382
13383
3/3
✓ Branch 0 taken 714 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 166 times.
964 switch(misc)
13384 {
13385 case 0:
13386
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 53 times.
84 if(wpnId!=wSword)
13387 31 return 0;
13388
13389 53 hp-=power;
13390
13391
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 12 times.
53 if(hp>0)
13392 {
13393 41 misc=1;
13394 41 Stunclk=64;
13395 41 }
13396 else
13397 {
13398 12 loadpalset(csBOSS,pSprite(spBROWN));
13399 12 misc=2;
13400 12 Stunclk=284;
13401 12 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
13402 }
13403
13404 53 sfx(WAV_EHIT,pan(x));
13405
13406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if(hitsfx>0) sfx(hitsfx,pan(x));
13407
13408 53 return 1;
13409
13410 case 2:
13411
4/6
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
166 if(wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4)
13412 154 return 0;
13413
13414 12 misc=3;
13415 12 hclk=81;
13416 12 loadpalset(9,pSprite(spBROWN));
13417 12 return 1;
13418 }
13419
13420 714 return 0;
13421 964 }
13422
13423 20776 void eGanon::draw(BITMAP *dest)
13424 {
13425
6/6
✓ Branch 0 taken 3608 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 983 times.
✓ Branch 3 taken 2535 times.
✓ Branch 4 taken 12680 times.
✓ Branch 5 taken 960 times.
20776 switch(misc)
13426 {
13427 case 0:
13428
2/2
✓ Branch 0 taken 9511 times.
✓ Branch 1 taken 3169 times.
12680 if((clk&3)==3)
13429 3169 tile=(zc_oldrand()%5)*2+o_tile;
13430
13431
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12680 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12680 if ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 ) //ganon is visible to level 2 amulet
13432 {
13433
13434 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
13435 {
13436 int odraw = drawstyle;
13437 drawstyle = 2;
13438 drawblock(dest,15);
13439 drawstyle = odraw;
13440 }
13441 else
13442 {
13443 drawblock(dest,15);
13444 }
13445 break;
13446
13447 }
13448
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12680 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12680 else if ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) )
13449 {
13450 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
13451 {
13452 int odraw = drawstyle;
13453 drawstyle = 2;
13454 drawblock(dest,15);
13455 drawstyle = odraw;
13456 }
13457 else
13458 {
13459 drawblock(dest,15);
13460 }
13461 break;
13462 }
13463
1/2
✓ Branch 0 taken 12680 times.
✗ Branch 1 not taken.
12680 if(db!=999)
13464 12680 break;
13465 [[fallthrough]];
13466 case 2:
13467
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 983 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
983 if(Stunclk<64 && (Stunclk&1))
13468 break;
13469 [[fallthrough]];
13470 case -1:
13471 3518 tile=o_tile;
13472
13473 [[fallthrough]];
13474 case 1:
13475 case 3:
13476 7126 drawblock(dest,15);
13477 7126 break;
13478
13479 case 4:
13480 960 draw_guts(dest);
13481 960 draw_flash(dest);
13482 960 break;
13483 }
13484 20776 }
13485
13486 960 void eGanon::draw_guts(BITMAP *dest)
13487 {
13488
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 204 times.
960 int32_t c = zc_min(clk>>3,8);
13489 960 tile = clk<24 ? 74 : 75;
13490 960 overtile16(dest,tile,x+8-viewport.x,y+c+playing_field_offset-viewport.y,9,0);
13491 960 overtile16(dest,tile,x+8-viewport.x,y+16-c+playing_field_offset-viewport.y,9,0);
13492 960 overtile16(dest,tile,x+c-viewport.x,y+8+playing_field_offset-viewport.y,9,0);
13493 960 overtile16(dest,tile,x+16-c-viewport.x,y+8+playing_field_offset-viewport.y,9,0);
13494 960 overtile16(dest,tile,x+c-viewport.x,y+c+playing_field_offset-viewport.y,9,0);
13495 960 overtile16(dest,tile,x+16-c-viewport.x,y+c+playing_field_offset-viewport.y,9,0);
13496 960 overtile16(dest,tile,x+c-viewport.x,y+16-c+playing_field_offset-viewport.y,9,0);
13497 960 overtile16(dest,tile,x+16-c-viewport.x,y+16-c+playing_field_offset-viewport.y,9,0);
13498 960 }
13499
13500 960 void eGanon::draw_flash(BITMAP *dest)
13501 {
13502
13503 960 int32_t c = clk-(clk>>2);
13504 960 cs = (frame&3)+6;
13505 960 overtile16(dest,194,x+8-viewport.x,y+8-clk+playing_field_offset-viewport.y,cs,0);
13506 960 overtile16(dest,194,x+8-viewport.x,y+8+clk+playing_field_offset-viewport.y,cs,2);
13507 960 overtile16(dest,195,x+8-clk-viewport.x,y+8+playing_field_offset-viewport.y,cs,0);
13508 960 overtile16(dest,195,x+8+clk-viewport.x,y+8+playing_field_offset-viewport.y,cs,1);
13509 960 overtile16(dest,196,x+8-c-viewport.x,y+8-c+playing_field_offset-viewport.y,cs,0);
13510 960 overtile16(dest,196,x+8+c-viewport.x,y+8-c+playing_field_offset-viewport.y,cs,1);
13511 960 overtile16(dest,196,x+8-c-viewport.x,y+8+c+playing_field_offset-viewport.y,cs,2);
13512 960 overtile16(dest,196,x+8+c-viewport.x,y+8+c+playing_field_offset-viewport.y,cs,3);
13513 960 }
13514
13515 15 void getBigTri(mapscr* scr, int32_t id2)
13516 {
13517 /*
13518 *************************
13519 * BIG TRIFORCE SEQUENCE *
13520 *************************
13521 0 BIGTRI out, WHITE flash in
13522 4 WHITE flash out, PILE cset white
13523 8 WHITE in
13524 ...
13525 188 WHITE out
13526 191 PILE cset red
13527 200 top SHUTTER opens
13528 209 bottom SHUTTER opens
13529 */
13530 15 sfx(itemsbuf[id2].playsound);
13531 15 guys.clear();
13532
13533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if(itemsbuf[id2].flags & item_gamedata)
13534 {
13535 game->lvlitems[dlevel]|=(1 << li_mcguffin);
13536 }
13537
13538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 setmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
13539
13540 15 draw_screen();
13541
13542
4/4
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 2880 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 2880 times.
2895 for(int32_t f=0; f<24*8 && !Quit; f++)
13543 {
13544
2/2
✓ Branch 0 taken 2865 times.
✓ Branch 1 taken 15 times.
2880 if(f==4)
13545 {
13546
2/2
✓ Branch 0 taken 225 times.
✓ Branch 1 taken 15 times.
240 for(int32_t i=1; i<16; i++)
13547 {
13548 225 RAMpal[CSET(9)+i]=_RGB(255,255,255);
13549 225 }
13550 15 }
13551
13552
2/2
✓ Branch 0 taken 2520 times.
✓ Branch 1 taken 360 times.
2880 if((f&7)==0)
13553 {
13554
2/2
✓ Branch 0 taken 1080 times.
✓ Branch 1 taken 360 times.
1440 for(int32_t cs=2; cs<5; cs++)
13555 {
13556
2/2
✓ Branch 0 taken 16200 times.
✓ Branch 1 taken 1080 times.
17280 for(int32_t i=1; i<16; i++)
13557 {
13558 16200 RAMpal[CSET(cs)+i]=_RGB(255,255,255);
13559 16200 }
13560 1080 }
13561
13562 360 refreshpal=true;
13563 360 }
13564
13565
2/2
✓ Branch 0 taken 2520 times.
✓ Branch 1 taken 360 times.
2880 if((f&7)==4)
13566 {
13567
1/2
✓ Branch 0 taken 360 times.
✗ Branch 1 not taken.
360 if(cur_screen<128) loadlvlpal(DMaps[cur_dmap].color);
13568 else loadlvlpal(0xB);
13569 360 }
13570
13571
2/2
✓ Branch 0 taken 2865 times.
✓ Branch 1 taken 15 times.
2880 if(f==191)
13572 {
13573 15 loadpalset(9,pSprite(spPILE));
13574 15 }
13575
13576 2880 advanceframe(true);
13577 2880 }
13578
13579 //play_DmapMusic();
13580 15 playLevelMusic();
13581
13582
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
15 if(itemsbuf[id2].flags & item_flag1 && cur_screen < 128)
13583 {
13584 2 Hero.dowarp(hero_scr, 1, 0); //side warp
13585 2 }
13586 15 }
13587
13588 //! No. I am not adding SIZEflags to Moldorm and Lanmola. -Z 12 Aug 2020
13589 618 eMoldorm::eMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13590 618 {
13591
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 if( !(editorflags & ENEMY_FLAG5) )
13592 {
13593
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 position_relative_to_screen(x, y, 128, 48);
13594 618 }
13595 //else { x = X; y = Y; }
13596
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 dir=(zc_oldrand()&7)+8;
13597 618 superman=1;
13598 618 fading=fade_invisible;
13599 618 hxofs=1000;
13600 618 segcnt=clk;
13601 618 segid=Id|0x1000;
13602 618 clk=0;
13603
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 id=guys.Count();
13604
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 618 times.
✗ Branch 3 not taken.
618 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
13605 618 tile=o_tile;
13606 618 hitdir = -1;
13607 618 stickclk = 0;
13608
13609 /*
13610 if (get_qr(qr_NEWENEMYTILES))
13611 {
13612 tile=nets+1220;
13613 }
13614 else
13615 {
13616 tile=57;
13617 }
13618 */
13619 618 }
13620
13621 244844 bool eMoldorm::animate(int32_t index)
13622 {
13623 244844 update_current_screen();
13624
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244844 times.
244844 if(switch_hooked) return enemy::animate(index);
13625 244844 int32_t max_y = isdungeon(screen_spawned) ? 100 : 100+28; //warning: Ugly hack. -Z
13626
2/2
✓ Branch 0 taken 216369 times.
✓ Branch 1 taken 28475 times.
244844 if ( y > (max_y) )
13627 {
13628 28475 ++stickclk; //Keep Moldorm from pacinn the bottom row or leaving the screen via the bottom edge. -Z 8th Sept, 2019
13629 //Z_scripterrlog("Stickclk is %d\n", stickclk);
13630 28475 }
13631
2/2
✓ Branch 0 taken 244282 times.
✓ Branch 1 taken 562 times.
244844 if ( stickclk > 45 )
13632 {
13633 562 stickclk = 0;
13634 562 newdir_8_old(rate,homing,spw_floater); //chage dir to keep from getting stuck.
13635 562 }
13636
13637
13638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244844 times.
244844 if(clk==0)
13639 {
13640 244844 removearmos(x,y);
13641 244844 }
13642
13643
2/2
✓ Branch 0 taken 2451 times.
✓ Branch 1 taken 242393 times.
244844 if(clk2)
13644 {
13645
2/2
✓ Branch 0 taken 2322 times.
✓ Branch 1 taken 129 times.
2451 if(--clk2 == 0)
13646 {
13647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(flags&guy_never_return)
13648 129 never_return(screen_spawned, index);
13649
13650
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if(!dmisc2 || (editorflags & ENEMY_FLAG6))
13651 129 leave_item();
13652
13653 129 stop_bgsfx(index);
13654 129 return true;
13655 }
13656 2322 }
13657 else
13658 {
13659
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if(stunclk>0)
13660 stunclk=0;
13661 242393 constant_walk_8_old(rate,homing,spw_floater);
13662
13663
13664 242393 misc=dir;
13665
13666 // If any higher-numbered segments were killed, segcnt can be too high,
13667 // leading to a crash
13668
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if(index+segcnt>=guys.Count())
13669 segcnt=guys.Count()-index-1;
13670
13671
2/2
✓ Branch 0 taken 242393 times.
✓ Branch 1 taken 1122281 times.
1364674 for(int32_t i=index+1; i<index+segcnt+1; i++)
13672 {
13673 1122281 enemy* segment=((enemy*)guys.spr(i));
13674
13675 // More validation - if segcnt was wrong, this may not
13676 // actually be a Moldorm segment
13677
1/2
✓ Branch 0 taken 1122281 times.
✗ Branch 1 not taken.
1122281 if(segment->id!=segid)
13678 {
13679 segcnt=i-index-1;
13680 break;
13681 }
13682
13683
2/2
✓ Branch 0 taken 879612 times.
✓ Branch 1 taken 242669 times.
1122281 if(i==index+1)
13684 {
13685 242669 x=segment->x;
13686 242669 y=segment->y;
13687 242669 }
13688
13689 1122281 segment->o_tile=tile; //I refuse to fuck with adding scripttile to segmented enemies. -Z
13690 //Script your own blasted segmented bosses!! -Z
13691 1122281 segment->setParent(this);
13692
4/4
✓ Branch 0 taken 242393 times.
✓ Branch 1 taken 879888 times.
✓ Branch 2 taken 24660 times.
✓ Branch 3 taken 217733 times.
1122281 if((i==index+segcnt)&&(i!=index+1)) //tail
13693 {
13694 217733 segment->dummy_int[1]=2;
13695 217733 }
13696 else
13697 {
13698 904548 segment->dummy_int[1]=1;
13699 }
13700
13701
2/2
✓ Branch 0 taken 879612 times.
✓ Branch 1 taken 242669 times.
1122281 if(i==index+1) //head
13702 {
13703 242669 segment->dummy_int[1]=0;
13704 242669 }
13705
13706
2/2
✓ Branch 0 taken 1121265 times.
✓ Branch 1 taken 1016 times.
1122281 if(segment->hp <= 0)
13707 {
13708 1016 int32_t offset=1;
13709
13710
2/2
✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 1480 times.
2496 for(int32_t j=i; j<index+segcnt; j++)
13711 {
13712 // Triple-check
13713
1/2
✓ Branch 0 taken 1480 times.
✗ Branch 1 not taken.
1480 if(((enemy*)guys.spr(j+1))->id!=segid)
13714 {
13715 segcnt=j-index+1; // Add 1 because of --segcnt below
13716 break;
13717 }
13718 1480 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
13719 1480 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
13720 1480 }
13721
13722 1016 segment->hclk=33;
13723 1016 --segcnt;
13724 1016 --i; // Recheck the same index in case multiple segments died at once
13725 1016 }
13726 1122281 }
13727
13728
2/2
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 242264 times.
242393 if(segcnt==0)
13729 {
13730 129 clk2=19;
13731
13732 129 x=guys.spr(index+1)->x;
13733 129 y=guys.spr(index+1)->y;
13734 129 }
13735 }
13736
13737 244715 return false;
13738 244844 }
13739
13740 3150 esMoldorm::esMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13741 3150 {
13742
1/2
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
3150 if( !(editorflags & ENEMY_FLAG5) )
13743 {
13744
1/2
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
3150 position_relative_to_screen(x, y, 128, 48);
13745 3150 }
13746
13747
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3150 times.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
3150 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
13748 3150 hyofs=4;
13749 3150 hit_width=hit_height=8;
13750 3150 hxofs=1000;
13751 3150 mainguy=count_enemy=false;
13752 3150 parentclk = 0;
13753 3150 bgsfx=-1;
13754
2/4
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
3150 flags&=~guy_never_return;
13755 //deadsfx = WAV_EDEAD;
13756 3150 isCore = false;
13757 3150 }
13758
13759 1138024 bool esMoldorm::animate(int32_t index)
13760 {
13761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1138024 times.
1138024 if(switch_hooked) return enemy::animate(index);
13762 // Shouldn't be possible, but better to be sure
13763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1138024 times.
1138024 if(index==0)
13764 dying=true;
13765
13766
2/2
✓ Branch 0 taken 15743 times.
✓ Branch 1 taken 1122281 times.
1138024 if(dying)
13767 {
13768
1/2
✓ Branch 0 taken 15743 times.
✗ Branch 1 not taken.
15743 if(!dmisc2)
13769 15743 item_set=0;
13770
13771 15743 return Dead(index);
13772 }
13773
13774
2/2
✓ Branch 0 taken 105077 times.
✓ Branch 1 taken 1017204 times.
1122281 if(clk>=0)
13775 {
13776 1017204 hxofs=4;
13777 1017204 step=((enemy*)guys.spr(index-1))->step;
13778
13779
2/2
✓ Branch 0 taken 70455 times.
✓ Branch 1 taken 946749 times.
1017204 if(parentclk == 0)
13780 {
13781 70455 misc=dir;
13782 70455 dir=((enemy*)guys.spr(index-1))->misc;
13783 //do alignment, as in parent's animation :-/ -DD
13784 70455 x.doFloor();
13785 70455 y.doFloor();
13786 70455 }
13787
13788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1017204 times.
1017204 if(step)
13789 1017204 parentclk=(parentclk+1)%((int32_t)(8.0/step));
13790
13791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1017204 times.
1017204 if(!watch)
13792 {
13793 1017204 sprite::move(step);
13794 1017204 }
13795 1017204 }
13796
13797 1122281 return enemy::animate(index);
13798 1138024 }
13799
13800 2683 int32_t esMoldorm::takehit(weapon *w, weapon* realweap)
13801 {
13802
2/2
✓ Branch 0 taken 2230 times.
✓ Branch 1 taken 453 times.
2683 if(enemy::takehit(w,realweap))
13803 2230 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
13804
13805 453 return 0;
13806 2683 }
13807
13808 1155313 void esMoldorm::draw(BITMAP *dest)
13809 {
13810 1155313 tile=o_tile;
13811 1155313 int32_t fdiv = frate/4;
13812
1/2
✓ Branch 0 taken 1155313 times.
✗ Branch 1 not taken.
1155313 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13813
13814
2/2
✓ Branch 0 taken 1043930 times.
✓ Branch 1 taken 111383 times.
1155313 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13815 1155313 efrate:((clk>=(frate>>1))?1:0);
13816
13817
2/2
✓ Branch 0 taken 111383 times.
✓ Branch 1 taken 1043930 times.
1155313 if(get_qr(qr_NEWENEMYTILES))
13818 {
13819 1043930 tile+=dummy_int[1]*40;
13820
13821
2/2
✓ Branch 0 taken 102730 times.
✓ Branch 1 taken 941200 times.
1043930 if(dir<8)
13822 {
13823 102730 flip=0;
13824
1/2
✓ Branch 0 taken 102730 times.
✗ Branch 1 not taken.
102730 tile+=4*zc_max(dir, 0); // dir is -1 if trapped
13825
13826
1/2
✓ Branch 0 taken 102730 times.
✗ Branch 1 not taken.
102730 if(dir>3) // Skip to the next row for diagonals
13827 tile+=4;
13828 102730 }
13829 else
13830 {
13831
8/9
✓ Branch 0 taken 96530 times.
✓ Branch 1 taken 134534 times.
✓ Branch 2 taken 113426 times.
✓ Branch 3 taken 124800 times.
✓ Branch 4 taken 101314 times.
✓ Branch 5 taken 99043 times.
✓ Branch 6 taken 131794 times.
✓ Branch 7 taken 139759 times.
✗ Branch 8 not taken.
941200 switch(dir-8) //directions get screwed up after 8. *shrug*
13832 {
13833 case up: //u
13834 96530 flip=0;
13835 96530 break;
13836
13837 case l_up: //d
13838 134534 flip=0;
13839 134534 tile+=4;
13840 134534 break;
13841
13842 case l_down: //l
13843 113426 flip=0;
13844 113426 tile+=8;
13845 113426 break;
13846
13847 case left: //r
13848 124800 flip=0;
13849 124800 tile+=12;
13850 124800 break;
13851
13852 case r_down: //ul
13853 101314 flip=0;
13854 101314 tile+=20;
13855 101314 break;
13856
13857 case down: //ur
13858 99043 flip=0;
13859 99043 tile+=24;
13860 99043 break;
13861
13862 case r_up: //dl
13863 131794 flip=0;
13864 131794 tile+=28;
13865 131794 break;
13866
13867 case right: //dr
13868 139759 flip=0;
13869 139759 tile+=32;
13870 139759 break;
13871 }
13872 }
13873
13874 1043930 tile+=f2;
13875 1043930 }
13876
13877
2/2
✓ Branch 0 taken 106267 times.
✓ Branch 1 taken 1049046 times.
1155313 if(clk>=0)
13878 1049046 enemy::draw(dest);
13879 1155313 }
13880
13881 420 eLanmola::eLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
13882 420 {
13883
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 if( !(editorflags & ENEMY_FLAG5) )
13884 {
13885
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 position_relative_to_screen(x, y, 64, 80);
13886 420 }
13887 //else { x = X; y = Y; }
13888 //byte legaldirs = 0;
13889 420 int32_t incr = 16;
13890 //int32_t possiiblepos = 0;
13891 //int32_t positions[8] = {0};
13892
13893 //Don't spawn in pits.
13894
5/8
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 420 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 315 times.
✓ Branch 7 taken 105 times.
420 if ( m_walkflag_simple(x, y) )
13895 {
13896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 for ( ; incr < 240; incr += 16 )
13897 {
13898 //move if we spawn over a pit
13899 //check each direction
13900
7/12
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 139 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 139 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 139 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 139 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 135 times.
139 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
13901 {
13902
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 x-=incr; break;
13903 }
13904
7/12
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 135 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 135 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 135 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 39 times.
✓ Branch 11 taken 96 times.
135 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
13905 {
13906
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 x+=incr; break;
13907 }
13908
9/16
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 96 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 96 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 96 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 96 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 96 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 32 times.
✓ Branch 15 taken 64 times.
96 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
13909 {
13910
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
32 x-=incr; y-=incr; break;
13911 }
13912
9/16
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 64 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 64 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 64 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 64 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 64 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 4 times.
✓ Branch 15 taken 60 times.
64 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
13913 {
13914
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 x+=incr; y-=incr; break;
13915 }
13916
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
13917 {
13918 y -= incr; break;
13919 }
13920
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
13921 {
13922 y+=incr; break;
13923 }
13924
9/16
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 60 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 60 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 26 times.
✓ Branch 15 taken 34 times.
60 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
13925 {
13926
2/4
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
26 x-=incr; y+=incr; break;
13927 }
13928
8/16
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 34 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 34 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 34 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 34 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 34 times.
34 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
13929 {
13930 x+=incr; y+=incr; break;
13931 }
13932 34 else continue;
13933
13934 }
13935
13936 105 }
13937
13938 420 dir=up;
13939 420 superman=1;
13940 420 fading=fade_invisible;
13941 420 hxofs=1000;
13942 420 segcnt=clk;
13943 420 clk=0;
13944 //set up move history
13945
2/2
✓ Branch 0 taken 420 times.
✓ Branch 1 taken 3060 times.
3480 for(int32_t i=0; i <= (1<<dmisc2); i++)
13946
3/6
✓ Branch 0 taken 3060 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3060 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3060 times.
✗ Branch 5 not taken.
3060 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
13947 420 }
13948
13949 236907 bool eLanmola::animate(int32_t index)
13950 {
13951
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 236907 times.
236907 if(switch_hooked) return enemy::animate(index);
13952
2/2
✓ Branch 0 taken 196711 times.
✓ Branch 1 taken 40196 times.
236907 if(clk==0)
13953 {
13954 40196 removearmos(x,y);
13955 40196 }
13956
13957
2/2
✓ Branch 0 taken 3591 times.
✓ Branch 1 taken 233316 times.
236907 if(clk2)
13958 {
13959
2/2
✓ Branch 0 taken 3402 times.
✓ Branch 1 taken 189 times.
3591 if(--clk2 == 0)
13960 {
13961
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 103 times.
189 if(!dmisc3) //This checks if "segments drop items" isn't true, because if they don't drop items, then only killing the whole thing drops an item.
13962 86 leave_item();
13963
13964 189 stop_bgsfx(index);
13965 189 return true;
13966 }
13967
13968 3402 return false;
13969 }
13970
13971
13972 //this animation style plays ALL KINDS of havoc on the Lanmola segments, since it causes
13973 //the direction AND x,y position of the lanmola to vary in uncertain ways.
13974 //I've added a complete movement history to this enemy to compensate -DD
13975 233316 constant_walk(rate,homing,spw_none);
13976 233316 prevState.pop_front();
13977 233316 prevState.push_front(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix, zfix>(x,y), dir));
13978
13979 // This could cause a crash with Moldorms. I didn't see the same problem
13980 // with Lanmolas, but it looks like it ought to be possible, so here's
13981 // the same solution. - Saf
13982
1/2
✓ Branch 0 taken 233316 times.
✗ Branch 1 not taken.
233316 if(index+segcnt>=guys.Count())
13983 segcnt=guys.Count()-index-1;
13984
13985
2/2
✓ Branch 0 taken 233316 times.
✓ Branch 1 taken 966396 times.
1199712 for(int32_t i=index+1; i<index+segcnt+1; i++)
13986 {
13987 966396 enemy* segment=((enemy*)guys.spr(i));
13988
13989 // More validation in case segcnt is wrong
13990
1/2
✓ Branch 0 taken 966396 times.
✗ Branch 1 not taken.
966396 if((segment->id&0xFFF)!=(id&0xFFF))
13991 {
13992 segcnt=i-index-1;
13993 break;
13994 }
13995
13996 966396 segment->o_tile=o_tile;
13997 966396 segment->setParent(this);
13998
4/4
✓ Branch 0 taken 233316 times.
✓ Branch 1 taken 733080 times.
✓ Branch 2 taken 37616 times.
✓ Branch 3 taken 195700 times.
966396 if((i==index+segcnt)&&(i!=index+1))
13999 {
14000 195700 segment->dummy_int[1]=1; //tail
14001 195700 }
14002 else
14003 {
14004 770696 segment->dummy_int[1]=0;
14005 }
14006
14007
2/2
✓ Branch 0 taken 965227 times.
✓ Branch 1 taken 1169 times.
966396 if(segment->hp <= 0)
14008 {
14009
2/2
✓ Branch 0 taken 1169 times.
✓ Branch 1 taken 1961 times.
3130 for(int32_t j=i; j<index+segcnt; j++)
14010 {
14011 // Triple-check
14012
1/2
✓ Branch 0 taken 1961 times.
✗ Branch 1 not taken.
1961 if((((enemy*)guys.spr(j+1))->id&0xFFF)!=(id&0xFFF))
14013 {
14014 segcnt=j-index+1; // Add 1 because of --segcnt below
14015 break;
14016 }
14017 1961 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
14018 1961 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
14019 1961 }
14020
14021 1169 ((enemy*)guys.spr(i))->hclk=33;
14022 1169 --segcnt;
14023 1169 --i; // Recheck the same index in case multiple segments died at once
14024 1169 }
14025 966396 }
14026
14027
2/2
✓ Branch 0 taken 233127 times.
✓ Branch 1 taken 189 times.
233316 if(segcnt==0)
14028 {
14029 189 clk2=19;
14030 189 x=guys.spr(index+1)->x;
14031 189 y=guys.spr(index+1)->y;
14032 189 setmapflag(get_scr(screen_spawned), mTMPNORET);
14033 189 }
14034
14035 //this enemy is invincible.. BUT scripts don't know that, and can "kill" it by setting the hp negative.
14036 //which is... disastrous.
14037 233316 hp = 1;
14038 233316 return enemy::animate(index);
14039 236907 }
14040
14041 2267 esLanmola::esLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
14042 2267 {
14043
1/2
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
2267 if( !(editorflags & ENEMY_FLAG5) )
14044 {
14045
1/2
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
2267 position_relative_to_screen(x, y, 64, 80);
14046 2267 }
14047 2267 int32_t incr = 16;
14048 //Don't spawn in pits.
14049
5/8
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2267 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1742 times.
✓ Branch 7 taken 525 times.
2267 if ( m_walkflag_simple(x, y) )
14050 {
14051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
695 for ( ; incr < 240; incr += 16 )
14052 {
14053 //move if we spawn over a pit
14054 //check each direction
14055
7/12
✓ Branch 0 taken 695 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 695 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 695 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 695 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 695 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 20 times.
✓ Branch 11 taken 675 times.
695 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
14056 {
14057
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 x-=incr; break;
14058 }
14059
7/12
✓ Branch 0 taken 675 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 675 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 675 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 675 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 675 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 195 times.
✓ Branch 11 taken 480 times.
675 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
14060 {
14061
1/2
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
195 x+=incr; break;
14062 }
14063
9/16
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 480 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 480 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 480 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 480 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 480 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 480 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 160 times.
✓ Branch 15 taken 320 times.
480 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
14064 {
14065
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 160 times.
✗ Branch 3 not taken.
160 x-=incr; y-=incr; break;
14066 }
14067
9/16
✓ Branch 0 taken 320 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 320 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 320 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 320 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 320 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 320 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 320 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 20 times.
✓ Branch 15 taken 300 times.
320 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
14068 {
14069
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 x+=incr; y-=incr; break;
14070 }
14071
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
14072 {
14073 y -= incr; break;
14074 }
14075
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
14076 {
14077 y+=incr; break;
14078 }
14079
9/16
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 300 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 300 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 130 times.
✓ Branch 15 taken 170 times.
300 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
14080 {
14081
2/4
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
130 x-=incr; y+=incr; break;
14082 }
14083
8/16
✓ Branch 0 taken 170 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 170 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 170 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 170 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 170 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 170 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 170 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 170 times.
170 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
14084 {
14085 x+=incr; y+=incr; break;
14086 }
14087 170 else continue;
14088
14089 }
14090
14091 525 }
14092
14093 2267 hxofs=1000;
14094 2267 hit_width=8;
14095 2267 mainguy=false;
14096 2267 count_enemy=(id<0x2000)?true:false;
14097
14098 //set up move history
14099
2/2
✓ Branch 0 taken 2267 times.
✓ Branch 1 taken 16763 times.
19030 for(int32_t i=0; i <= (1<<dmisc2); i++)
14100
3/6
✓ Branch 0 taken 16763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16763 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16763 times.
✗ Branch 5 not taken.
16763 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
14101
14102 2267 bgsfx = -1;
14103 2267 isCore = false;
14104
2/4
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
2267 flags&=~guy_never_return;
14105 2267 }
14106
14107 985563 bool esLanmola::animate(int32_t index)
14108 {
14109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 985563 times.
985563 if(switch_hooked) return enemy::animate(index);
14110 // Shouldn't be possible, but who knows
14111
2/2
✓ Branch 0 taken 985545 times.
✓ Branch 1 taken 18 times.
985563 if(index==0)
14112 18 dying=true;
14113
14114
2/2
✓ Branch 0 taken 19167 times.
✓ Branch 1 taken 966396 times.
985563 if(dying)
14115 {
14116 19167 xofs=0;
14117
14118
2/2
✓ Branch 0 taken 9861 times.
✓ Branch 1 taken 9306 times.
19167 if(!dmisc3)
14119 9306 item_set=0;
14120
14121 19167 return Dead(index);
14122 }
14123
14124
2/2
✓ Branch 0 taken 35946 times.
✓ Branch 1 taken 930450 times.
966396 if(clk>=0)
14125 {
14126 930450 hxofs=4;
14127
14128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 930450 times.
930450 if(!watch)
14129 {
14130 930450 std::pair<std::pair<zfix, zfix>, int32_t> newstate = ((eBaseLanmola*)guys.spr(index-1))->prevState.front();
14131 930450 prevState.pop_front();
14132 930450 prevState.push_back(newstate);
14133 930450 x = newstate.first.first;
14134 930450 y = newstate.first.second;
14135 930450 dir = newstate.second;
14136 930450 }
14137 930450 }
14138
14139 966396 return enemy::animate(index);
14140 985563 }
14141
14142 2655 int32_t esLanmola::takehit(weapon *w, weapon* realweap)
14143 {
14144
2/2
✓ Branch 0 taken 2065 times.
✓ Branch 1 taken 590 times.
2655 if(enemy::takehit(w,realweap))
14145 2065 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
14146
14147 590 return 0;
14148 2655 }
14149
14150 990931 void esLanmola::draw(BITMAP *dest)
14151 {
14152 990931 tile=o_tile;
14153 990931 int32_t fdiv = frate/4;
14154
1/2
✓ Branch 0 taken 990931 times.
✗ Branch 1 not taken.
990931 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14155
14156
2/2
✓ Branch 0 taken 628932 times.
✓ Branch 1 taken 361999 times.
990931 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14157 990931 efrate:((clk>=(frate>>1))?1:0);
14158
14159
2/2
✓ Branch 0 taken 628932 times.
✓ Branch 1 taken 361999 times.
990931 if(get_qr(qr_NEWENEMYTILES))
14160 {
14161
2/2
✓ Branch 0 taken 147165 times.
✓ Branch 1 taken 481767 times.
628932 if(id>=0x2000)
14162 {
14163 481767 tile+=20;
14164
14165
2/2
✓ Branch 0 taken 353025 times.
✓ Branch 1 taken 128742 times.
481767 if(dummy_int[1]==1)
14166 {
14167 128742 tile+=20;
14168 128742 }
14169 481767 }
14170
14171
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 141419 times.
✓ Branch 2 taken 140994 times.
✓ Branch 3 taken 159500 times.
✓ Branch 4 taken 187019 times.
628932 switch(dir)
14172 {
14173 case up:
14174 141419 flip=0;
14175 141419 break;
14176
14177 case down:
14178 140994 flip=0;
14179 140994 tile+=4;
14180 140994 break;
14181
14182 case left:
14183 159500 flip=0;
14184 159500 tile+=8;
14185 159500 break;
14186
14187 case right:
14188 187019 flip=0;
14189 187019 tile+=12;
14190 187019 break;
14191 }
14192
14193 628932 tile+=f2;
14194 628932 }
14195 else
14196 {
14197
2/2
✓ Branch 0 taken 90543 times.
✓ Branch 1 taken 271456 times.
361999 if(id>=0x2000)
14198 {
14199 271456 tile+=1;
14200 271456 }
14201 }
14202
14203
2/2
✓ Branch 0 taken 37038 times.
✓ Branch 1 taken 953893 times.
990931 if(clk>=0)
14204 953893 enemy::draw(dest);
14205 990931 }
14206
14207 150 eManhandla::eManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
14208 150 {
14209 //these are here to bypass compiler warnings about unused arguments
14210 150 Clk=Clk;
14211 150 superman=1;
14212
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 dir=(zc_oldrand()&7)+8;
14213 150 armcnt=dmisc2?8:4;//((id==eMANHAN)?4:8);
14214
14215
2/2
✓ Branch 0 taken 692 times.
✓ Branch 1 taken 150 times.
842 for(int32_t i=0; i<armcnt; i++)
14216 692 arm[i]=i;
14217
14218 150 fading=fade_blue_poof;
14219 //nets+4680;
14220 150 adjusted=false;
14221
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
150 if (SIZEflags != 0) init_size_flags();;
14222 150 }
14223
14224 66494 bool eManhandla::animate(int32_t index)
14225 {
14226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66494 times.
66494 if(switch_hooked) return enemy::animate(index);
14227
2/2
✓ Branch 0 taken 1382 times.
✓ Branch 1 taken 65112 times.
66494 if(dying)
14228 1382 return Dead(index);
14229
14230
2/2
✓ Branch 0 taken 62641 times.
✓ Branch 1 taken 2471 times.
65112 if(clk==0)
14231 {
14232 2471 removearmos(x,y);
14233 2471 }
14234
14235
14236 // check arm status, move dead ones to end of group
14237
2/2
✓ Branch 0 taken 193618 times.
✓ Branch 1 taken 65112 times.
258730 for(int32_t i=0; i<armcnt; i++)
14238 {
14239 193618 enemy* cur_arm = ((enemy*)guys.spr(index+i+1));
14240
3/4
✓ Branch 0 taken 193618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 424 times.
✓ Branch 3 taken 193194 times.
193618 if(!cur_arm || cur_arm->dying)
14241 {
14242
2/2
✓ Branch 0 taken 552 times.
✓ Branch 1 taken 424 times.
976 for(int32_t j=i; j<armcnt-1; j++)
14243 {
14244 552 zc_swap(arm[j],arm[j+1]);
14245 552 guys.swap(index+j+1,index+j+2);
14246 552 }
14247
2/2
✓ Branch 0 taken 337 times.
✓ Branch 1 taken 87 times.
424 if((editorflags & ENEMY_FLAG6)) //They only did this in 2.10
14248 {
14249 87 leave_item();
14250 87 }
14251 424 --armcnt;
14252 424 --i;
14253 424 continue;
14254 }
14255
2/2
✓ Branch 0 taken 192502 times.
✓ Branch 1 taken 692 times.
193194 if(!adjusted)
14256 {
14257
2/2
✓ Branch 0 taken 508 times.
✓ Branch 1 taken 184 times.
692 if(!dmisc2)
14258 {
14259 508 cur_arm->o_tile=o_tile+40;
14260 508 cur_arm->setParent(this);
14261 508 }
14262 else
14263 {
14264 184 cur_arm->o_tile=o_tile+160;
14265 184 cur_arm->setParent(this);
14266 }
14267 692 }
14268 193194 }
14269
14270 65112 adjusted=true;
14271
14272 // move or die
14273
2/2
✓ Branch 0 taken 65029 times.
✓ Branch 1 taken 83 times.
65112 if(armcnt==0)
14274 83 hp=0;
14275 else
14276 {
14277 // Speed starts at 0.5, and increases by 0.5 for each head lost. Max speed is 4.5.
14278
2/2
✓ Branch 0 taken 53584 times.
✓ Branch 1 taken 11445 times.
65029 step = ((dmisc2 ? 8_zf : 4_zf) - armcnt) * 0.5 + (dstep / 100);
14279
1/2
✓ Branch 0 taken 65029 times.
✗ Branch 1 not taken.
65029 if (step > 4.5_zf) step = 4.5_zf;
14280 65029 int32_t dx1=0, dy1=-8, dx2=15, dy2=15;
14281
14282
2/2
✓ Branch 0 taken 53584 times.
✓ Branch 1 taken 11445 times.
65029 if(!dmisc2)
14283 {
14284
2/2
✓ Branch 0 taken 151019 times.
✓ Branch 1 taken 53584 times.
204603 for(int32_t i=0; i<armcnt; i++)
14285 {
14286
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 38579 times.
✓ Branch 2 taken 36328 times.
✓ Branch 3 taken 36250 times.
✓ Branch 4 taken 39862 times.
151019 switch(arm[i])
14287 {
14288 case 0:
14289 38579 dy1=-24;
14290 38579 break;
14291
14292 case 1:
14293 36328 dy2=31;
14294 36328 break;
14295
14296 case 2:
14297 36250 dx1=-16;
14298 36250 break;
14299
14300 case 3:
14301 39862 dx2=31;
14302 39862 break;
14303 }
14304 151019 }
14305 53584 }
14306 else
14307 {
14308 11445 dx1=-8, dy1=-16, dx2=23, dy2=23;
14309
14310
2/2
✓ Branch 0 taken 42175 times.
✓ Branch 1 taken 11445 times.
53620 for(int32_t i=0; i<armcnt; i++)
14311 {
14312
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 12012 times.
✓ Branch 2 taken 7730 times.
✓ Branch 3 taken 9837 times.
✓ Branch 4 taken 12596 times.
42175 switch(arm[i]&3)
14313 {
14314 case 0:
14315 12012 dy1=-32;
14316 12012 break;
14317
14318 case 1:
14319 7730 dy2=39;
14320 7730 break;
14321
14322 case 2:
14323 9837 dx1=-24;
14324 9837 break;
14325
14326 case 3:
14327 12596 dx2=39;
14328 12596 break;
14329 }
14330 42175 }
14331 }
14332
14333 65029 variable_walk_8(rate,homing,hrate,spw_floater,dx1,dy1,dx2,dy2);
14334
14335
2/2
✓ Branch 0 taken 193194 times.
✓ Branch 1 taken 65029 times.
258223 for(int32_t i=0; i<armcnt; i++)
14336 {
14337 193194 zfix dx=(zfix)0,dy=(zfix)0;
14338
14339
2/2
✓ Branch 0 taken 151019 times.
✓ Branch 1 taken 42175 times.
193194 if(!dmisc2)
14340 {
14341
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 38579 times.
✓ Branch 2 taken 36328 times.
✓ Branch 3 taken 36250 times.
✓ Branch 4 taken 39862 times.
151019 switch(arm[i])
14342 {
14343 case 0:
14344 38579 dy=-16;
14345 38579 break;
14346
14347 case 1:
14348 36328 dy=16;
14349 36328 break;
14350
14351 case 2:
14352 36250 dx=-16;
14353 36250 break;
14354
14355 case 3:
14356 39862 dx=16;
14357 39862 break;
14358 }
14359 151019 }
14360 else
14361 {
14362
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 5447 times.
✓ Branch 2 taken 3986 times.
✓ Branch 3 taken 4163 times.
✓ Branch 4 taken 6774 times.
✓ Branch 5 taken 6565 times.
✓ Branch 6 taken 3744 times.
✓ Branch 7 taken 5674 times.
✓ Branch 8 taken 5822 times.
42175 switch(arm[i])
14363 {
14364 case 0:
14365 5447 dy=-24;
14366 5447 dx=-8;
14367 5447 break;
14368
14369 case 1:
14370 3986 dy=24;
14371 3986 dx=8;
14372 3986 break;
14373
14374 case 2:
14375 4163 dx=-24;
14376 4163 dy=8;
14377 4163 break;
14378
14379 case 3:
14380 6774 dx=24;
14381 6774 dy=-8;
14382 6774 break;
14383
14384 case 4:
14385 6565 dy=-24;
14386 6565 dx=8;
14387 6565 break;
14388
14389 case 5:
14390 3744 dy=24;
14391 3744 dx=-8;
14392 3744 break;
14393
14394 case 6:
14395 5674 dx=-24;
14396 5674 dy=-8;
14397 5674 break;
14398
14399 case 7:
14400 5822 dx=24;
14401 5822 dy=8;
14402 5822 break;
14403 }
14404 }
14405
14406 193194 guys.spr(index+i+1)->x = x+dx;
14407 193194 guys.spr(index+i+1)->y = y+dy;
14408 193194 }
14409 }
14410
14411 65112 return enemy::animate(index);
14412 66494 }
14413
14414
14415 1751 int32_t eManhandla::takehit(weapon *w, weapon* realweap)
14416 {
14417 1751 int32_t wpnId = w->id;
14418
14419
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1751 times.
1751 if(dying)
14420 return 0;
14421
14422
3/4
✓ Branch 0 taken 923 times.
✓ Branch 1 taken 786 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
1751 switch(wpnId)
14423 {
14424 case wBomb:
14425 case wSBomb:
14426 case wSword:
14427 case wHammer:
14428 case wWand:
14429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 786 times.
786 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(x));
14430
14431 case wLitBomb:
14432 case wLitSBomb:
14433 case wBait:
14434 case wWhistle:
14435 case wFire:
14436 case wWind:
14437 case wSSparkle:
14438 case wFSparkle:
14439 case wPhantom:
14440 1709 return 0;
14441
14442 case wHookshot:
14443 case wBrang:
14444 sfx(WAV_CHINK,pan(x));
14445 break;
14446
14447 default:
14448
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(x));
14449 else sfx(WAV_CHINK,pan(x));
14450
14451 42 }
14452
14453 42 return 1;
14454 1751 }
14455
14456 66490 void eManhandla::draw(BITMAP *dest)
14457 {
14458 66490 tile=o_tile;
14459 66490 int32_t fdiv = frate/4;
14460
1/2
✓ Branch 0 taken 66490 times.
✗ Branch 1 not taken.
66490 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14461
14462
2/2
✓ Branch 0 taken 48802 times.
✓ Branch 1 taken 17688 times.
66490 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14463 66490 efrate:((clk>=(frate>>1))?1:0);
14464
14465
2/2
✓ Branch 0 taken 48802 times.
✓ Branch 1 taken 17688 times.
66490 if(get_qr(qr_NEWENEMYTILES))
14466 {
14467
2/2
✓ Branch 0 taken 11308 times.
✓ Branch 1 taken 37494 times.
48802 if(!dmisc2)
14468 {
14469
8/9
✓ Branch 0 taken 4771 times.
✓ Branch 1 taken 4640 times.
✓ Branch 2 taken 4995 times.
✓ Branch 3 taken 5574 times.
✓ Branch 4 taken 3793 times.
✓ Branch 5 taken 3930 times.
✓ Branch 6 taken 3908 times.
✓ Branch 7 taken 5883 times.
✗ Branch 8 not taken.
37494 switch(dir-8) //directions get screwed up after 8. *shrug*
14470 {
14471 case up: //u
14472 4771 flip=0;
14473 4771 break;
14474
14475 case l_up: //d
14476 4640 flip=0;
14477 4640 tile+=4;
14478 4640 break;
14479
14480 case l_down: //l
14481 4995 flip=0;
14482 4995 tile+=8;
14483 4995 break;
14484
14485 case left: //r
14486 5574 flip=0;
14487 5574 tile+=12;
14488 5574 break;
14489
14490 case r_down: //ul
14491 3793 flip=0;
14492 3793 tile+=20;
14493 3793 break;
14494
14495 case down: //ur
14496 3930 flip=0;
14497 3930 tile+=24;
14498 3930 break;
14499
14500 case r_up: //dl
14501 3908 flip=0;
14502 3908 tile+=28;
14503 3908 break;
14504
14505 case right: //dr
14506 5883 flip=0;
14507 5883 tile+=32;
14508 5883 break;
14509 }
14510
14511 37494 tile+=f2;
14512 37494 enemy::draw(dest);
14513 37494 } //manhandla 2, big body
14514 else
14515 {
14516
14517
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 1277 times.
✓ Branch 2 taken 1360 times.
✓ Branch 3 taken 2242 times.
✓ Branch 4 taken 1789 times.
✓ Branch 5 taken 1345 times.
✓ Branch 6 taken 805 times.
✓ Branch 7 taken 948 times.
✓ Branch 8 taken 1542 times.
11308 switch(dir-8) //directions get screwed up after 8. *shrug*
14518 {
14519 case up: //u
14520 1277 flip=0;
14521 1277 break;
14522
14523 case l_up: //d
14524 1360 flip=0;
14525 1360 tile+=8;
14526 1360 break;
14527
14528 case l_down: //l
14529 2242 flip=0;
14530 2242 tile+=40;
14531 2242 break;
14532
14533 case left: //r
14534 1789 flip=0;
14535 1789 tile+=48;
14536 1789 break;
14537
14538 case r_down: //ul
14539 1345 flip=0;
14540 1345 tile+=80;
14541 1345 break;
14542
14543 case down: //ur
14544 805 flip=0;
14545 805 tile+=88;
14546 805 break;
14547
14548 case r_up: //dl
14549 948 flip=0;
14550 948 tile+=120;
14551 948 break;
14552
14553 case right: //dr
14554 1542 flip=0;
14555 1542 tile+=128;
14556 1542 break;
14557 }
14558
14559 11308 tile+=(f2*2);
14560 11308 xofs-=8;
14561 11308 yofs-=8;
14562 11308 drawblock(dest,15);
14563 11308 xofs+=8;
14564 11308 yofs+=8;
14565 }
14566 48802 }
14567 else
14568 {
14569
2/2
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 17173 times.
17688 if(!dmisc2)
14570 {
14571 17173 enemy::draw(dest);
14572 17173 }
14573 else
14574 {
14575 515 xofs-=8;
14576 515 yofs-=8;
14577 515 enemy::draw(dest);
14578 515 xofs+=16;
14579 515 enemy::draw(dest);
14580 515 yofs+=16;
14581 515 enemy::draw(dest);
14582 515 xofs-=16;
14583 515 enemy::draw(dest);
14584 515 xofs+=8;
14585 515 yofs-=8;
14586 }
14587 }
14588 66490 }
14589
14590 692 esManhandla::esManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14591 692 {
14592 692 id=misc=clk;
14593 692 dir = clk & 3;
14594 692 clk=0;
14595 692 mainguy=count_enemy=false;
14596 692 dummy_bool[0]=false;
14597 692 item_set=0;
14598 692 bgsfx=-1;
14599 692 deadsfx = WAV_EDEAD;
14600
2/4
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 692 times.
✗ Branch 3 not taken.
692 flags &= (~guy_never_return);
14601 692 isCore = false;
14602
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 692 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
692 if (SIZEflags != 0) init_size_flags();;
14603 692 }
14604
14605 200202 bool esManhandla::animate(int32_t index)
14606 {
14607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200202 times.
200202 if(switch_hooked) return enemy::animate(index);
14608
2/2
✓ Branch 0 taken 7008 times.
✓ Branch 1 taken 193194 times.
200202 if(dying)
14609 7008 return Dead(index);
14610
14611
2/2
✓ Branch 0 taken 12404 times.
✓ Branch 1 taken 180790 times.
193194 if(clk==0)
14612 {
14613 12404 removearmos(x,y);
14614 12404 }
14615
14616
2/2
✓ Branch 0 taken 165298 times.
✓ Branch 1 taken 27896 times.
193194 if(--clk2<=0)
14617 {
14618 27896 clk2=unsigned(zc_oldrand())%5+5;
14619 27896 clk3^=1;
14620 27896 }
14621
14622
2/2
✓ Branch 0 taken 1491 times.
✓ Branch 1 taken 191703 times.
193194 if(!(zc_oldrand()&127))
14623 {
14624 1491 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
14625 1491 sfx(wpnsfx(wpn),pan(x));
14626 1491 }
14627
14628 193194 return enemy::animate(index);
14629 200202 }
14630
14631 200186 void esManhandla::draw(BITMAP *dest)
14632 {
14633 200186 tile=o_tile;
14634 200186 int32_t fdiv = frate/4;
14635
1/2
✓ Branch 0 taken 200186 times.
✗ Branch 1 not taken.
200186 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14636
2/2
✓ Branch 0 taken 158716 times.
✓ Branch 1 taken 41470 times.
200186 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14637 200186 efrate:((clk>=(frate>>1))?1:0);
14638
14639
2/2
✓ Branch 0 taken 158716 times.
✓ Branch 1 taken 41470 times.
200186 if(get_qr(qr_NEWENEMYTILES))
14640 {
14641
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 39945 times.
✓ Branch 2 taken 36845 times.
✓ Branch 3 taken 39966 times.
✓ Branch 4 taken 41960 times.
158716 switch(misc&3)
14642 {
14643 case up:
14644 39945 break;
14645
14646 case down:
14647 36845 tile+=4;
14648 36845 break;
14649
14650 case left:
14651 39966 tile+=8;
14652 39966 break;
14653
14654 case right:
14655 41960 tile+=12;
14656 41960 break;
14657 }
14658
14659 158716 tile+=f2;
14660 158716 }
14661 else
14662 {
14663
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 12394 times.
✓ Branch 2 taken 7883 times.
✓ Branch 3 taken 8961 times.
✓ Branch 4 taken 12232 times.
41470 switch(misc&3)
14664 {
14665 case down:
14666 8961 flip=2;
14667
14668 [[fallthrough]];
14669 case up:
14670 21355 tile=(clk3)?188:189;
14671 21355 break;
14672
14673 case right:
14674 12232 flip=1;
14675 [[fallthrough]];
14676
14677 case left:
14678 20115 tile=(clk3)?186:187;
14679 20115 break;
14680 }
14681 }
14682
14683 200186 enemy::draw(dest);
14684 200186 }
14685
14686 168 eGleeok::eGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) //enemy((zfix)120,(zfix)48,Id,Clk)
14687 168 {
14688
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if ( !(editorflags & ENEMY_FLAG5) )
14689 {
14690
2/4
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 168 times.
✗ Branch 3 not taken.
168 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, 120, 48);
14691 168 }
14692 else
14693 {
14694 if ( !(editorflags & ENEMY_FLAG6) )
14695 {
14696 x = X; y = Y;
14697 }
14698 else
14699 {
14700 x = X+8; y = Y;
14701 }
14702 }
14703 168 hzsz = 32; // can't be jumped.
14704 168 flameclk=0;
14705 168 misc=clk; // total head count
14706 168 clk3=clk; // live head count
14707 168 clk=0;
14708 168 clk2=60; // fire ball clock
14709 // hp=(guysbuf[eGLEEOK2+(misc-2)].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[eGLEEOK2+(misc-2)].hp;
14710
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 hp=(guysbuf[id&0xFFF].attributes[1])*(misc-1)*game->get_hero_dmgmult()+guysbuf[id&0xFFF].hp;
14711 168 dir = down;
14712 168 hxofs=4;
14713 168 hit_width=8;
14714 // frate=17*4;
14715 168 fading=fade_blue_poof;
14716 //nets+5420;
14717
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 35 times.
168 if(get_qr(qr_NEWENEMYTILES))
14718 {
14719 /*
14720 necktile=o_tile+8;
14721 if (dmisc3)
14722 {
14723 necktile+=8;
14724 }
14725 */
14726 133 necktile=o_tile+dmisc6;
14727 133 }
14728 else
14729 {
14730 35 necktile=s_tile;
14731 }
14732 168 }
14733
14734 155290 bool eGleeok::animate(int32_t index)
14735 {
14736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 155290 times.
155290 if(switch_hooked) return enemy::animate(index);
14737
2/2
✓ Branch 0 taken 2199 times.
✓ Branch 1 taken 153091 times.
155290 if(dying)
14738 2199 return Dead(index);
14739
14740
2/2
✓ Branch 0 taken 152407 times.
✓ Branch 1 taken 684 times.
153091 if(clk==0)
14741 {
14742 684 removearmos(x,y);
14743 684 }
14744
14745 // Check if a head was killed somehow...
14746
2/2
✓ Branch 0 taken 101719 times.
✓ Branch 1 taken 51372 times.
153091 if(index+1+clk3>=guys.Count())
14747 51372 clk3=guys.Count()-index-1;
14748
2/2
✓ Branch 0 taken 66050 times.
✓ Branch 1 taken 87041 times.
153091 if(index+1+misc>=guys.Count())
14749 87041 misc=guys.Count()-index-1;
14750
14751 //fix for the "kill all enemies" item
14752
2/2
✓ Branch 0 taken 153085 times.
✓ Branch 1 taken 6 times.
153091 if(hp==-1000)
14753 {
14754
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<clk3; ++i)
14755 {
14756 // I haven't seen this fail, but it seems like it ought to be
14757 // possible, so I'm checking for it. - Saf
14758
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
14759 break;
14760 12 ((enemy*)guys.spr(index+i+1))->hp=1; // re-animate each head,
14761 12 ((enemy*)guys.spr(index+i+1))->misc = -1; // disconnect it,
14762 12 ((enemy*)guys.spr(index+i+1))->animate(index+i+1); // let it animate one frame,
14763 12 ((enemy*)guys.spr(index+i+1))->hp=-1000; // and kill it for good
14764 12 }
14765
14766 6 clk3=0;
14767
14768
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<misc; i++)
14769 {
14770
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
14771 break;
14772 12 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
14773 12 }
14774 6 }
14775
14776
2/2
✓ Branch 0 taken 403171 times.
✓ Branch 1 taken 153091 times.
556262 for(int32_t i=0; i<clk3; i++)
14777 {
14778 403171 enemy *head = ((enemy*)guys.spr(index+i+1));
14779 403171 head->dummy_int[1]=necktile;
14780 403171 head->setParent(this);
14781
14782
2/2
✓ Branch 0 taken 320127 times.
✓ Branch 1 taken 83044 times.
403171 if(get_qr(qr_NEWENEMYTILES))
14783 {
14784 320127 head->dummy_int[2]=o_tile+dmisc8; //connected head tile
14785 320127 head->dummy_int[3]=o_tile+dmisc9; //flying head tile
14786 320127 }
14787 else
14788 {
14789 83044 head->dummy_int[2]=necktile+1; //connected head tile
14790 83044 head->dummy_int[3]=necktile+2; //flying head tile
14791 }
14792
14793 403171 head->dmisc5=dmisc5; //neck segments
14794
14795 /*
14796 if (dmisc3)
14797 {
14798 head->dummy_bool[0]=true;
14799 }
14800 */
14801
2/2
✓ Branch 0 taken 397516 times.
✓ Branch 1 taken 5655 times.
403171 if(head->hclk)
14802 {
14803
2/2
✓ Branch 0 taken 4427 times.
✓ Branch 1 taken 1228 times.
5655 if(hclk==0)
14804 {
14805 1228 hp -= 1000 - head->hp;
14806 1228 hclk = 33;
14807
14808
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1228 times.
1228 if(hitsfx>0) sfx(hitsfx,pan(int32_t(head->x)));
14809
14810 1228 sfx(WAV_EHIT,pan(int32_t(head->x)));
14811 1228 }
14812
14813 5655 head->hclk = 0;
14814 5655 }
14815
14816 // Must be set in case of naughty ZScripts
14817 403171 head->hp = 1000;
14818 403171 }
14819
14820
2/2
✓ Branch 0 taken 152676 times.
✓ Branch 1 taken 415 times.
153091 if(hp<=(guysbuf[id&0xFFF].attributes[1]) * (clk3 - 1) * game->get_hero_dmgmult())
14821 {
14822 415 ((enemy*)guys.spr(index+clk3))->misc = -1; // give signal to fly off
14823 415 hp=(guysbuf[id&0xFFF].attributes[1])*(--clk3)*game->get_hero_dmgmult();
14824 415 }
14825
14826
2/2
✓ Branch 0 taken 57409 times.
✓ Branch 1 taken 95682 times.
153091 if(!dmisc3)
14827 {
14828
4/4
✓ Branch 0 taken 5291 times.
✓ Branch 1 taken 90391 times.
✓ Branch 2 taken 1287 times.
✓ Branch 3 taken 4004 times.
95682 if(++clk2>72 && !(zc_oldrand()&3))
14829 {
14830 1287 int32_t i = zc::math::SafeMod(zc_oldrand(), misc);
14831 1287 enemy *head = ((enemy*)guys.spr(index+i+1));
14832 1287 addEwpn(head->x,head->y,head->z,wpn,3,wdp,dir,getUID(), 0, head->fakez);
14833 1287 sfx(wpnsfx(wpn),pan(x));
14834 1287 clk2=0;
14835 1287 }
14836 95682 }
14837 else
14838 {
14839
4/4
✓ Branch 0 taken 2357 times.
✓ Branch 1 taken 55052 times.
✓ Branch 2 taken 1800 times.
✓ Branch 3 taken 557 times.
57409 if(++clk2>100 && !(zc_oldrand()&3))
14840 {
14841 557 enemy *head = ((enemy*)guys.spr(zc::math::SafeMod(zc_oldrand(), misc) + index + 1));
14842 557 head->timer=zc_oldrand()%50+50;
14843 557 clk2=0;
14844 557 }
14845 }
14846
14847
3/4
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 152964 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
153091 if((hp<=0 && !immortal))
14848 {
14849
2/2
✓ Branch 0 taken 390 times.
✓ Branch 1 taken 127 times.
517 for(int32_t i=0; i<misc; i++)
14850 390 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
14851
14852
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 124 times.
127 if(flags&guy_never_return) never_return(screen_spawned, index);
14853 127 }
14854
14855 153091 return enemy::animate(index);
14856 155290 }
14857
14858 1239 int32_t eGleeok::takehit(weapon*,weapon*)
14859 {
14860 1239 return 0;
14861 }
14862
14863 156918 void eGleeok::draw(BITMAP *dest)
14864 {
14865 156918 tile=o_tile;
14866
14867
2/2
✓ Branch 0 taken 2199 times.
✓ Branch 1 taken 154719 times.
156918 if(dying)
14868 {
14869 2199 enemy::draw(dest);
14870 2199 return;
14871 }
14872
14873 154719 int32_t f=clk/17;
14874
14875
2/2
✓ Branch 0 taken 120524 times.
✓ Branch 1 taken 34195 times.
154719 if(get_qr(qr_NEWENEMYTILES))
14876 {
14877 // body
14878 120524 xofs=-8;
14879 120524 yofs=32;
14880
14881
4/4
✓ Branch 0 taken 92588 times.
✓ Branch 1 taken 9155 times.
✓ Branch 2 taken 10095 times.
✓ Branch 3 taken 8686 times.
120524 switch(f)
14882
14883 {
14884 case 0:
14885 9155 tile+=0;
14886 9155 break;
14887
14888 case 1:
14889 10095 tile+=2;
14890 10095 break;
14891
14892 case 2:
14893 8686 tile+=4;
14894 8686 break;
14895
14896 default:
14897 92588 tile+=6;
14898 92588 break;
14899 }
14900 120524 }
14901 else
14902 {
14903 // body
14904 34195 xofs=-8;
14905 34195 yofs=32;
14906
14907
3/3
✓ Branch 0 taken 29222 times.
✓ Branch 1 taken 2514 times.
✓ Branch 2 taken 2459 times.
34195 switch(f)
14908 {
14909 case 0:
14910 2514 tile+=0;
14911 2514 break;
14912
14913 case 2:
14914 2459 tile+=4;
14915 2459 break;
14916
14917 default:
14918 29222 tile+=2;
14919 29222 break;
14920 }
14921 }
14922
14923 154719 enemy::drawblock(dest,15);
14924 156918 }
14925
14926 156918 void eGleeok::draw2(BITMAP *dest)
14927 {
14928 // the neck stub
14929 156918 tile=necktile;
14930 156918 xofs=0;
14931
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156918 times.
156918 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14932
14933
2/2
✓ Branch 0 taken 34737 times.
✓ Branch 1 taken 122181 times.
156918 if(get_qr(qr_NEWENEMYTILES))
14934 {
14935 122181 tile+=((clk&24)>>3);
14936 122181 }
14937
14938
3/4
✓ Branch 0 taken 154719 times.
✓ Branch 1 taken 2199 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 154719 times.
156918 if(hp > 0 && !dont_draw())
14939 {
14940 154719 mapscr* scr = get_scr(screen_spawned);
14941
4/4
✓ Branch 0 taken 4731 times.
✓ Branch 1 taken 149988 times.
✓ Branch 2 taken 737 times.
✓ Branch 3 taken 3994 times.
154719 if((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
14942 737 sprite::drawcloaked(dest);
14943 else
14944 153982 sprite::draw(dest);
14945 154719 }
14946 156918 }
14947
14948
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
1066 esGleeok::esGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk)
14949 533 {
14950
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 setParent(prnt);
14951
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 xoffset=0;
14952
2/4
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
533 yoffset=(zfix)((dmisc5*4+2));
14953 // dummy_bool[0]=false;
14954 533 timer=0;
14955 /* fixing */
14956 533 hp=1000;
14957
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 step=1;
14958 533 item_set=0;
14959
4/8
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 533 times.
✗ Branch 7 not taken.
533 x = xoffset+parent->x;
14960
4/8
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 533 times.
✗ Branch 7 not taken.
533 y = yoffset+parent->y;
14961 533 hxofs=4;
14962 533 hit_width=8;
14963
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 533 times.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
533 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14964 533 clk2=clk; // how int32_t to wait before moving first time
14965 533 clk=0;
14966 533 mainguy=count_enemy=false;
14967
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 dir=zc_oldrand();
14968 533 clk3=((dir&2)>>1)+2; // left or right
14969 533 dir&=1; // up or down
14970
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 dmisc5=vbound(dmisc5,1,255);
14971 533 isCore = false;
14972
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 parentCore = parent->getUID();
14973
2/2
✓ Branch 0 taken 2132 times.
✓ Branch 1 taken 533 times.
2665 for(int32_t i=0; i<dmisc5; i++)
14974 {
14975 2132 nxoffset[i] = 0;
14976 2132 nyoffset[i] = 0;
14977
2/4
✓ Branch 0 taken 2132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2132 times.
✗ Branch 3 not taken.
2132 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5);
14978
2/4
✓ Branch 0 taken 2132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2132 times.
✗ Branch 3 not taken.
2132 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5);
14979 2132 }
14980
14981 533 necktile=0;
14982 //TODO compatibility? -DD
14983 /*
14984 for(int32_t i=0; i<4; i++)
14985 {
14986 nx[i]=124;
14987 ny[i]=i*6+48;
14988 }*/
14989 533 bgsfx=-1;
14990 //no need for deadsfx
14991 533 }
14992
14993 515535 bool esGleeok::animate(int32_t index)
14994 {
14995
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 515535 times.
515535 if(switch_hooked) return enemy::animate(index);
14996 // don't call removearmos() - it's a segment.
14997
14998 515535 dmisc5=vbound(dmisc5,1,255);
14999
15000
2/2
✓ Branch 0 taken 112773 times.
✓ Branch 1 taken 402762 times.
515535 if(misc == 0)
15001 {
15002 402762 x = (xoffset+parent->x);
15003 402762 y = (yoffset+parent->y);
15004
15005
2/2
✓ Branch 0 taken 1611048 times.
✓ Branch 1 taken 402762 times.
2013810 for(int32_t i=0; i<dmisc5; i++)
15006 {
15007 1611048 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5) + 3 + nxoffset[i];
15008 1611048 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5) + nyoffset[i];
15009 1611048 }
15010 402762 }
15011
15012 // set up the head tiles
15013 // headtile=nets+5588; //5580, actually. must adjust for direction later on
15014 /*
15015 if (dummy_bool[0]) //if this is a flame gleeok
15016 {
15017 headtile+=180;
15018 }
15019 */
15020 515535 headtile=dummy_int[2]; //5580, actually. must adjust for direction later on
15021 515535 flyingheadtile=dummy_int[3];
15022
15023 // set up the neck tiles
15024 515535 necktile=dummy_int[1];
15025
15026
2/2
✓ Branch 0 taken 112702 times.
✓ Branch 1 taken 402833 times.
515535 if(get_qr(qr_NEWENEMYTILES))
15027 {
15028 402833 necktile+=((clk&24)>>3);
15029 402833 }
15030
15031 /*
15032 else
15033 {
15034 necktile=145;
15035 }
15036 */
15037 // ?((dummy_bool[0])?(nets+4052+(16+((clk&24)>>3))):(nets+4040+(8+((clk&24)>>3)))):145)
15038
15039
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 402762 times.
✓ Branch 2 taken 112071 times.
✓ Branch 3 taken 300 times.
✓ Branch 4 taken 402 times.
515535 switch(misc)
15040 {
15041 case 0: // live head
15042 // set up the attached head tiles
15043 402762 tile=headtile;
15044
15045
2/2
✓ Branch 0 taken 82942 times.
✓ Branch 1 taken 319820 times.
402762 if(get_qr(qr_NEWENEMYTILES))
15046 {
15047 319820 tile+=((clk&24)>>3);
15048 /*
15049 if (dummy_bool[0]) {
15050 tile+=1561;
15051 }
15052 */
15053 319820 }
15054
15055 /*
15056 else
15057 {
15058 tile=146;
15059 }
15060 */
15061
4/4
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 298314 times.
✓ Branch 2 taken 11616 times.
✓ Branch 3 taken 92832 times.
402762 if(++clk2>=0 && !(clk2&3))
15062 {
15063
2/2
✓ Branch 0 taken 90773 times.
✓ Branch 1 taken 2059 times.
92832 if(y<= (int32_t)parent->y + 8) dir=down;
15064
15065
2/2
✓ Branch 0 taken 90911 times.
✓ Branch 1 taken 1921 times.
92832 if(y>= (int32_t)parent->y + dmisc5*8) dir = up;
15066
15067
4/4
✓ Branch 0 taken 9757 times.
✓ Branch 1 taken 83075 times.
✓ Branch 2 taken 9465 times.
✓ Branch 3 taken 292 times.
92832 if(y<= (int32_t)parent->y + 10 && !(zc_oldrand()&31))
15068 {
15069 292 dir^=1;
15070 292 }
15071
15072 92832 zfix tempx = x;
15073 92832 zfix tempy = y;
15074
15075 92832 sprite::move(step);
15076 92832 xoffset += (x-tempx);
15077 92832 yoffset += (y-tempy);
15078
15079
2/2
✓ Branch 0 taken 3863 times.
✓ Branch 1 taken 88969 times.
92832 if(clk2>=4)
15080 {
15081 3863 clk3^=1;
15082 3863 clk2=-4;
15083 3863 }
15084 else
15085 {
15086
2/2
✓ Branch 0 taken 87991 times.
✓ Branch 1 taken 978 times.
88969 if(x <= (int32_t)parent->x-(dmisc5*6))
15087 {
15088 978 clk3=right;
15089 978 }
15090
15091
2/2
✓ Branch 0 taken 88008 times.
✓ Branch 1 taken 961 times.
88969 if(x >= (int32_t)parent->x+(dmisc5*6))
15092 {
15093 961 clk3=left;
15094 961 }
15095
15096
4/4
✓ Branch 0 taken 60029 times.
✓ Branch 1 taken 28940 times.
✓ Branch 2 taken 56316 times.
✓ Branch 3 taken 3713 times.
88969 if(y <= (int32_t)parent->y+(dmisc5*6) && !(zc_oldrand()&15))
15097 {
15098 3713 clk3^=1; // x jig
15099 3713 }
15100 else
15101 {
15102
4/4
✓ Branch 0 taken 29223 times.
✓ Branch 1 taken 56033 times.
✓ Branch 2 taken 28372 times.
✓ Branch 3 taken 851 times.
85256 if(y<=(int32_t)parent->y+(dmisc5*4) && !(zc_oldrand()&31))
15103 {
15104 851 clk3^=1; // x switch back
15105 851 }
15106
15107 85256 clk2=-4;
15108 }
15109 }
15110
15111 92832 zc_swap(dir,clk3);
15112 92832 tempx = x;
15113 92832 tempy = y;
15114 92832 sprite::move(step);
15115 92832 xoffset += (x-tempx);
15116 92832 yoffset += (y-tempy);
15117 92832 zc_swap(dir,clk3);
15118
15119
2/2
✓ Branch 0 taken 278496 times.
✓ Branch 1 taken 92832 times.
371328 for(int32_t i=1; i<dmisc5; i++)
15120 {
15121 278496 nxoffset[i] = (zc_oldrand()%3);
15122 278496 nyoffset[i] = (zc_oldrand()%3);
15123 278496 }
15124 92832 }
15125
15126 402762 break;
15127
15128 case 1: // flying head
15129
2/2
✓ Branch 0 taken 6589 times.
✓ Branch 1 taken 105482 times.
112071 if(clk>=0)
15130
15131 {
15132 105482 variable_walk_8(rate,homing,hrate,spw_floater);
15133 105482 }
15134
15135 112071 break;
15136
15137 // the following are messages sent from the main guy...
15138 case -1: // got chopped off
15139 {
15140 300 misc=1;
15141 300 superman=1;
15142 300 hxofs=xofs=0;
15143 300 hit_width=16;
15144 300 cs=8;
15145 300 clk=-24;
15146 300 clk2=40;
15147 300 dir=(zc_oldrand()&7)+8;
15148 300 step=8.0/9.0;
15149 }
15150 300 break;
15151
15152 case -2: // the big guy is dead
15153 402 return true;
15154 }
15155
15156
2/2
✓ Branch 0 taken 475008 times.
✓ Branch 1 taken 40125 times.
515133 if(timer)
15157 {
15158
2/2
✓ Branch 0 taken 35334 times.
✓ Branch 1 taken 4791 times.
40125 if(!(timer%8))
15159 {
15160 4791 FireBreath(true);
15161 4791 }
15162
15163 40125 --timer;
15164 40125 }
15165
15166 515133 return enemy::animate(index);
15167 515535 }
15168
15169 7080 int32_t esGleeok::takehit(weapon *w, weapon* realweap)
15170 {
15171
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7080 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7080 if ((editorflags & ENEMY_FLAG7) && misc == 1)
15172 {
15173 int32_t wpnId = w->id;
15174
15175 if(dying)
15176 return 0;
15177
15178 switch(wpnId)
15179 {
15180 case wLitBomb:
15181 case wLitSBomb:
15182 case wBait:
15183 case wWhistle:
15184 case wFire:
15185 case wWind:
15186 case wSSparkle:
15187 case wFSparkle:
15188 case wPhantom:
15189 return 0;
15190
15191 case wHookshot:
15192 case wBrang:
15193 case wBeam:
15194 case wArrow:
15195 case wMagic:
15196 case wBomb:
15197 case wSBomb:
15198 sfx(WAV_CHINK,pan(x));
15199 break;
15200 default:
15201 break;
15202 }
15203
15204 return 1;
15205 }
15206 else
15207 {
15208 7080 int32_t ret = enemy::takehit(w,realweap);
15209
15210
2/2
✓ Branch 0 taken 1425 times.
✓ Branch 1 taken 5655 times.
7080 if(ret==-1)
15211 5655 return -2; // force it to wait a frame before checking sword attacks again
15212
15213 1425 return ret;
15214 }
15215 7080 }
15216
15217 521456 void esGleeok::draw(BITMAP *dest)
15218 {
15219 521456 dmisc5=vbound(dmisc5,1,255);
15220
15221
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 409106 times.
✓ Branch 2 taken 112350 times.
521456 switch(misc)
15222 {
15223 case 0: //neck
15224
1/2
✓ Branch 0 taken 409106 times.
✗ Branch 1 not taken.
409106 if(!dont_draw())
15225 {
15226
2/2
✓ Branch 0 taken 1227318 times.
✓ Branch 1 taken 409106 times.
1636424 for(int32_t i=1; i<dmisc5; i++) //draw the neck
15227 {
15228 1227318 mapscr* scr = get_scr(screen_spawned);
15229
2/2
✓ Branch 0 taken 978198 times.
✓ Branch 1 taken 249120 times.
1227318 if(get_qr(qr_NEWENEMYTILES))
15230 {
15231
4/4
✓ Branch 0 taken 23100 times.
✓ Branch 1 taken 955098 times.
✓ Branch 2 taken 20889 times.
✓ Branch 3 taken 2211 times.
978198 if((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15232 2211 overtilecloaked16(dest,necktile+(i*dmisc7),nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,0);
15233 else
15234 975987 overtile16(dest,necktile+(i*dmisc7),nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,cs,0);
15235 978198 }
15236 else
15237 {
15238
3/4
✓ Branch 0 taken 4278 times.
✓ Branch 1 taken 244842 times.
✓ Branch 2 taken 4278 times.
✗ Branch 3 not taken.
249120 if((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15239 overtilecloaked16(dest,necktile,nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,0);
15240 else
15241 249120 overtile16(dest,necktile,nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,cs,0);
15242 }
15243 1227318 }
15244 409106 }
15245
15246 409106 break;
15247
15248 case 1: //flying head
15249 112350 tile=flyingheadtile;
15250
15251
2/2
✓ Branch 0 taken 82692 times.
✓ Branch 1 taken 29658 times.
112350 if(get_qr(qr_NEWENEMYTILES))
15252 {
15253 82692 tile+=((clk&24)>>3);
15254 82692 break;
15255 }
15256 29658 }
15257 521456 }
15258
15259 521456 void esGleeok::draw2(BITMAP *dest)
15260 {
15261 521456 enemy::draw(dest);
15262 521456 }
15263
15264 190 ePatra::ePatra(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)// enemy((zfix)128,(zfix)48,Id,Clk)
15265 190 {
15266
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ( !(editorflags & ENEMY_FLAG5) )
15267 {
15268
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 x = 128;
15269
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 y = 48;
15270 190 }
15271 else { x = X; y = Y; }
15272 190 adjusted=false;
15273
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 dir=(zc_oldrand()&7)+8;
15274 //step=0.25;
15275 190 flycnt=dmisc1;
15276 190 flycnt2=dmisc2;
15277 190 loopcnt=0;
15278 190 clk4 = 0;
15279 190 clk5 = 0;
15280 190 clk6 = 0;
15281 190 clk7 = 0;
15282
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
15283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc29 == 0)
15284 {
15285
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15286 {
15287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc29 = (90 / 3);
15288 105 else dmisc29 = (84 / 3);
15289 105 }
15290 else
15291 {
15292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc29 = (90 / 2);
15293 85 else dmisc29 = (84 / 2);
15294 }
15295 190 }
15296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc30 == 0)
15297 {
15298
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15299 {
15300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc30 = (90 / 3)*0.5;
15301 105 else dmisc30 = (84 / 3)*0.5;
15302 105 }
15303 else
15304 {
15305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc30 = (90 / 2)*0.5;
15306 85 else dmisc30 = (84 / 2)*0.5;
15307 }
15308 190 }
15309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc31 == 0)
15310 {
15311
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15312 {
15313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc31 = (90 / 3)*2;
15314 105 else dmisc31 = (84 / 3)*2;
15315 105 }
15316 else
15317 {
15318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc31 = (90 / 2)*0.5;
15319 85 else dmisc31 = (84 / 2)*0.5;
15320 }
15321 190 }
15322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc32 == 0)
15323 {
15324
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15325 {
15326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc32 = (90 / 3);
15327 105 else dmisc32 = (84 / 3);
15328 105 }
15329 else
15330 {
15331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc32 = (90 / 2)*0.25;
15332 85 else dmisc32 = (84 / 2)*0.25;
15333 }
15334 190 }
15335
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 init_size_flags();
15336 190 }
15337
15338 161885 bool ePatra::animate(int32_t index)
15339 {
15340
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 161885 times.
161885 if(switch_hooked) return enemy::animate(index);
15341
2/2
✓ Branch 0 taken 1444 times.
✓ Branch 1 taken 160441 times.
161885 if(dying)
15342 {
15343
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 1444 times.
1516 for(int32_t i=index+1; i<index+flycnt+flycnt2+1; i++)
15344 {
15345 72 auto segment = (enemy*)guys.spr(i);
15346
2/4
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 72 times.
72 if (segment && segment->parent == this)
15347 72 segment->hp = -1000;
15348 72 }
15349
15350 1444 return Dead(index);
15351 }
15352
15353 160441 double basesize = 84;
15354
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (dmisc10) basesize = 90;
15355 160441 double halfsize = basesize / 2;
15356 160441 double quartersize = halfsize / 2;
15357 160441 double twothirdsize = (basesize / 3)*2;
15358 160441 double onethirdsize = (basesize / 3);
15359
15360
15361
2/2
✓ Branch 0 taken 123507 times.
✓ Branch 1 taken 36934 times.
160441 if(clk==0)
15362 {
15363 36934 removearmos(x,y);
15364 36934 }
15365
15366
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 160441 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
160441 if ((clk4 <=0 || clk4%2) && (clk7 <= 0 || clk6 <= -16))
15367 {
15368
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
160441 if (!dmisc22 || loopcnt == 0 || (dmisc22 == 1 && loopcnt < 0)) variable_walk_8(rate,homing,hrate,spw_floater);
15369
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (loopcnt < 0) ++clk2;
15370
2/2
✓ Branch 0 taken 158644 times.
✓ Branch 1 taken 1797 times.
160441 if(++clk2>basesize)
15371 {
15372 1797 clk2=0;
15373
2/12
✗ Branch 0 not taken.
✓ Branch 1 taken 1797 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1797 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
1797 if ((!dmisc26 || (dmisc26 == 1 && flycnt) || (dmisc26 == 2 && !flycnt)) && (!(editorflags & ENEMY_FLAG10) || flycnt || flycnt2))
15374 {
15375
2/2
✓ Branch 0 taken 932 times.
✓ Branch 1 taken 865 times.
1797 if(loopcnt > 0)
15376 932 --loopcnt;
15377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
865 else if (loopcnt == 0)
15378 {
15379
2/2
✓ Branch 0 taken 509 times.
✓ Branch 1 taken 356 times.
865 if (zc::math::SafeMod(misc, dmisc6) == 0)
15380 {
15381
1/2
✓ Branch 0 taken 356 times.
✗ Branch 1 not taken.
356 if (dmisc21 > 0) loopcnt=-dmisc21;
15382 356 else loopcnt=dmisc7;
15383 356 }
15384 865 }
15385 else if (loopcnt == -1) loopcnt=dmisc7;
15386 else ++loopcnt;
15387
15388
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1797 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1797 if (!(editorflags & ENEMY_FLAG9) || loopcnt == 0) ++misc;
15389 1797 }
15390 else
15391 {
15392 loopcnt = 0;
15393 misc = 1;
15394 }
15395 1797 }
15396 160441 }
15397
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk4 > 0) --clk4;
15398
15399
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk6 < 0)
15400 {
15401 if (dmisc5 == 1 || dmisc5 == 3)
15402 {
15403 if (get_qr(qr_NEWENEMYTILES))
15404 {
15405 if (clk7 <= 0 || clk6 != -16) ++clk6;
15406 if (clk6 == 0) o_tile=d->e_tile;
15407 else
15408 {
15409 if (clk6 >= -16) o_tile=d->e_tile + (IsBigAnim() ? 320 : 80);
15410 else o_tile=d->e_tile + (IsBigAnim() ? 160 : 40);
15411 }
15412 }
15413 else clk6 = 0;
15414 }
15415 }
15416
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 else if (dmisc19) ++clk6;
15417
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk5 < 0) ++clk5;
15418
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 else if (dmisc19) ++clk5;
15419
15420
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
160441 if (clk7 > 0 && clk6 >= -16) --clk7;
15421
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk6 > 0) clk7 = 0;
15422
15423
2/2
✓ Branch 0 taken 660384 times.
✓ Branch 1 taken 160441 times.
820825 for(int32_t i=index+1; i<index+flycnt+1; i++)
15424 {
15425 //outside ring
15426
2/2
✓ Branch 0 taken 659040 times.
✓ Branch 1 taken 1344 times.
660384 if(!adjusted)
15427 {
15428
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 192 times.
1344 if(get_qr(qr_NEWENEMYTILES))
15429 {
15430 1152 ((enemy*)guys.spr(i))->o_tile=d->e_tile+dmisc8;
15431 1152 enemy *s = ((enemy*)guys.spr(i));
15432 1152 s->setParent(this);
15433 1152 }
15434 else
15435 {
15436 192 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
15437 192 enemy *s = ((enemy*)guys.spr(i));
15438 192 s->setParent(this);
15439 }
15440
15441 1344 ((enemy*)guys.spr(i))->cs=dmisc9;
15442 1344 ((enemy*)guys.spr(i))->hp=dmisc3;
15443 1344 }
15444
15445
2/2
✓ Branch 0 taken 764 times.
✓ Branch 1 taken 659620 times.
660384 if(((enemy*)guys.spr(i))->hp <= 0)
15446 {
15447
2/2
✓ Branch 0 taken 2889 times.
✓ Branch 1 taken 764 times.
3653 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
15448 {
15449 2889 guys.swap(j,j+1);
15450 2889 }
15451
15452
3/4
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 670 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
764 if (--flycnt == 0 && dmisc23 != 0) step += zslongToFix(dmisc23*100);
15453 764 }
15454 else
15455 {
15456 659620 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
15457
1/2
✓ Branch 0 taken 659620 times.
✗ Branch 1 not taken.
659620 double a2 = (clk2-pos2*(double)basesize/(dmisc1 == 0 ? 1 : dmisc1))*PI/halfsize;
15458
15459
2/2
✓ Branch 0 taken 212037 times.
✓ Branch 1 taken 447583 times.
659620 if(!dmisc4) //Big Ring
15460 {
15461 //maybe playing_field_offset here?
15462
2/2
✓ Branch 0 taken 237330 times.
✓ Branch 1 taken 210253 times.
447583 if(loopcnt>0)
15463 {
15464
1/2
✓ Branch 0 taken 237330 times.
✗ Branch 1 not taken.
237330 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc31) - zc::math::Sin(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
15465
1/2
✓ Branch 0 taken 237330 times.
✗ Branch 1 not taken.
237330 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc31) + zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
15466 237330 }
15467 else
15468 {
15469 210253 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15470 210253 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
15471 }
15472
15473 447583 temp_x=guys.spr(i)->x;
15474 447583 temp_y=guys.spr(i)->y;
15475 447583 }
15476 else //Oval
15477 {
15478 212037 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15479 212037 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
15480
15481
2/2
✓ Branch 0 taken 121041 times.
✓ Branch 1 taken 90996 times.
212037 if(loopcnt>0)
15482 {
15483 121041 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15484
1/2
✓ Branch 0 taken 121041 times.
✗ Branch 1 not taken.
121041 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1)))*abs(dmisc31);
15485 121041 }
15486 else
15487 {
15488 90996 guys.spr(i)->x = circle_x;
15489 90996 guys.spr(i)->y = circle_y;
15490 }
15491
15492 212037 temp_x=circle_x;
15493 212037 temp_y=circle_y;
15494 }
15495
15496 double _MSVC2022_tmp1, _MSVC2022_tmp2;
15497 659620 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
15498
15499
4/4
✓ Branch 0 taken 124008 times.
✓ Branch 1 taken 535612 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 83117 times.
659620 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
15500 {
15501 83117 guys.spr(i)->dir=l_down;
15502 83117 }
15503
4/4
✓ Branch 0 taken 124459 times.
✓ Branch 1 taken 452044 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 83568 times.
576503 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
15504 {
15505 83568 guys.spr(i)->dir=left;
15506 83568 }
15507
4/4
✓ Branch 0 taken 123345 times.
✓ Branch 1 taken 369590 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 82454 times.
492935 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
15508 {
15509 82454 guys.spr(i)->dir=l_up;
15510 82454 }
15511
4/4
✓ Branch 0 taken 123079 times.
✓ Branch 1 taken 287402 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 82188 times.
410481 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
15512 {
15513 82188 guys.spr(i)->dir=up;
15514 82188 }
15515
4/4
✓ Branch 0 taken 122491 times.
✓ Branch 1 taken 205802 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81600 times.
328293 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
15516 {
15517 81600 guys.spr(i)->dir=r_up;
15518 81600 }
15519
4/4
✓ Branch 0 taken 122884 times.
✓ Branch 1 taken 123809 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81993 times.
246693 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
15520 {
15521 81993 guys.spr(i)->dir=right;
15522 81993 }
15523
4/4
✓ Branch 0 taken 122590 times.
✓ Branch 1 taken 42110 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81699 times.
164700 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
15524 {
15525 81699 guys.spr(i)->dir=r_down;
15526 81699 }
15527 else
15528 {
15529 83001 guys.spr(i)->dir=down;
15530 }
15531
15532 659620 guys.spr(i)->x += x;
15533 659620 guys.spr(i)->y += y;
15534 }
15535 660384 }
15536
15537
7/22
✓ Branch 0 taken 106957 times.
✓ Branch 1 taken 53484 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 106957 times.
✓ Branch 4 taken 21153 times.
✓ Branch 5 taken 32331 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 21153 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 32331 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
160441 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==1 || dmisc5== 3) && (!dmisc25 || (dmisc25 == 1 && !flycnt && !flycnt2) || (dmisc25 == 2 && (flycnt || flycnt2)) || (dmisc25 == 3 && flycnt2 && !flycnt)))
15538 {
15539 32331 int timeneeded = 48;
15540 32331 int patbreath = (zc_oldrand()%50+50);
15541
2/2
✓ Branch 0 taken 24549 times.
✓ Branch 1 taken 7782 times.
32331 if ((patbreath % 4) == 0) ++patbreath;
15542
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (dmisc28 == patratBREATH)
15543 {
15544 timeneeded = 48 + patbreath;
15545 }
15546
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (dmisc28 == patratSTREAM)
15547 {
15548 timeneeded = 48 + 96;
15549 }
15550
4/14
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 32331 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 249 times.
✓ Branch 11 taken 249 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
32331 if (((((dmisc18 > 0 || ((editorflags & ENEMY_FLAG10) && !flycnt && !flycnt2)) && !(zc_oldrand() % zc_max(dmisc18, 1))) || //New 1/N chance
15551
2/2
✓ Branch 0 taken 32331 times.
✓ Branch 1 taken 249 times.
32580 (dmisc18 == 0 && !(zc_oldrand()&127)) //Old hardcoded firing chance
15552
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 32082 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
32580 || (dmisc18 == -1 && loopcnt > 0 && (clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15553 || (clk4 == 10 && (editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)))))
15554 249 && (clk6 >= 0) //if not in the middle of firing...
15555 249 && clk6 >= dmisc19) //if over the set cooldown between shots...
15556
2/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 249 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
249 && ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > timeneeded)) || dmisc18 == -1)) //And lastly, if not in danger of starting a loop during the attack.
15557 {
15558
1/3
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
249 switch(dmisc28)
15559 {
15560 case patratSTREAM:
15561 {
15562 clk7 = 97;
15563 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
15564 else clk6 = 0;
15565 break;
15566 }
15567 case patratBREATH:
15568 {
15569 clk7 = patbreath;
15570 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
15571 else clk6 = 0;
15572 break;
15573 }
15574 default:
15575 {
15576
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
249 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15577 {
15578 clk6 = -48;
15579 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15580 }
15581 else
15582 {
15583 249 clk6 = 0;
15584
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15585 249 FirePatraWeapon();
15586 }
15587 249 break;
15588 }
15589 } //ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
15590 249 }
15591
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (clk6 < 0)
15592 {
15593 switch(dmisc28)
15594 {
15595 case patratSTREAM:
15596 {
15597 if (clk7 > 0 && (clk7 % 12) == 0) FirePatraWeapon();
15598 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15599 break;
15600 }
15601 case patratBREATH:
15602 {
15603 if (clk7 > 0 && (clk7 % 4) == 0) FirePatraWeapon();
15604 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15605 break;
15606 }
15607 default:
15608 {
15609 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && clk6 == -16)
15610 {
15611 FirePatraWeapon();
15612 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15613 }
15614 break;
15615 }
15616 }
15617 }
15618 32331 }
15619
15620 160441 int randattempts = 0;
15621 160441 int randeye = 0;
15622
2/2
✓ Branch 0 taken 114201 times.
✓ Branch 1 taken 46240 times.
160441 if (flycnt2 > 0)
15623 {
15624 46240 do
15625 {
15626
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46240 times.
✓ Branch 2 taken 44221 times.
✓ Branch 3 taken 2019 times.
46240 randeye = ((flycnt2 > 0) ? (zc_oldrand() % zc_max(1, flycnt2)) : 0);
15627 46240 randeye += (index + flycnt + 1);
15628 46240 ++randattempts;
15629
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46240 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 46240 times.
46240 } while (((esPatra*)guys.spr(randeye))->clk5 < 0 && randattempts < 10);
15630 46240 }
15631 160441 bool dofire = false;
15632
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (dmisc20)
15633 {
15634 if ((dmisc18 > 0 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
15635 (dmisc18 == 0 && !(zc_oldrand()&127)) ||
15636 (dmisc18 == -1 && (loopcnt > 0 || dmisc20 == 4) && ((clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES)) && dmisc20 != 2 && dmisc20 != 4)
15637 || (clk2 == 10 && dmisc20 != 4 && ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) || dmisc20 == 2))
15638 || (((((zc::math::SafeMod(misc, dmisc6) == 0 && (loopcnt == 0 && !dmisc21)) || loopcnt > 1 || loopcnt == -1) && clk2 <= 53 && clk2 >= 51 && (editorflags & ENEMY_FLAG3)) || (!(editorflags & ENEMY_FLAG3) && loopcnt > 0 && clk2 == 1)) && dmisc20 == 4))))
15639 {
15640 if (clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15641 {
15642 if (clk5 >= dmisc19)
15643 {
15644 if ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
15645 (dmisc20 == 2 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > ((int64_t)48 + (int64_t(12)*flycnt2))) ||
15646 (dmisc20 == 4 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > ((int64_t)48 + 96)) ||
15647 (dmisc20 != 2 && dmisc20 != 4 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > 48)))
15648 || dmisc18 == -1)
15649 dofire = true;
15650 }
15651 }
15652 }
15653 }
15654
2/2
✓ Branch 0 taken 114201 times.
✓ Branch 1 taken 46240 times.
160441 if(flycnt2)
15655 {
15656
2/2
✓ Branch 0 taken 334429 times.
✓ Branch 1 taken 46240 times.
380669 for(int32_t i=index+flycnt+1; i<index+flycnt+flycnt2+1; i++)//inner ring
15657 {
15658
2/2
✓ Branch 0 taken 334117 times.
✓ Branch 1 taken 312 times.
334429 if(!adjusted)
15659 {
15660 312 ((enemy*)guys.spr(i))->hp=12*game->get_hero_dmgmult();
15661
15662
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if(get_qr(qr_NEWENEMYTILES))
15663 {
15664
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
15665 {
15666
2/3
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 168 times.
✗ Branch 2 not taken.
312 switch(dmisc5)
15667 {
15668 // Center eye shoots projectiles; make room for its firing tiles
15669 case 1:
15670 case 3:
15671 144 ((enemy*)guys.spr(i))->o_tile=d->e_tile+120;
15672 144 break;
15673
15674 // Center eyes does not shoot; use tiles two rows below for inner eyes.
15675 default:
15676 case 2:
15677 168 ((enemy*)guys.spr(i))->o_tile=d->e_tile+40;
15678 168 break;
15679 }
15680 312 }
15681 else ((enemy*)guys.spr(i))->o_tile = d->s_tile;
15682 312 }
15683 else
15684 {
15685 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
15686 }
15687
15688 312 ((enemy*)guys.spr(i))->cs=dmisc9;
15689
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if (dmisc27) ((enemy*)guys.spr(i))->hp=dmisc27;
15690 312 }
15691
15692
2/2
✓ Branch 0 taken 263816 times.
✓ Branch 1 taken 70613 times.
334429 if(flycnt>0)
15693 {
15694 263816 ((enemy*)guys.spr(i))->superman=true;
15695 263816 }
15696 else
15697 {
15698 70613 ((enemy*)guys.spr(i))->superman=false;
15699 }
15700
15701
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 334284 times.
334429 if(((enemy*)guys.spr(i))->hp <= 0)
15702 {
15703
2/2
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 145 times.
414 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
15704 {
15705 269 guys.swap(j,j+1);
15706 269 }
15707
15708
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 127 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
145 if (--flycnt2 == 0 && dmisc24 != 0) step += zslongToFix(dmisc24*100);
15709 145 }
15710 else
15711 {
15712 334284 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
15713
1/2
✓ Branch 0 taken 334284 times.
✗ Branch 1 not taken.
334284 double a2 = ((clk2-pos2*basesize/(dmisc2==0 ? 1 : dmisc2))*PI/(halfsize));
15714
15715
2/2
✓ Branch 0 taken 7259 times.
✓ Branch 1 taken 327025 times.
334284 if(dmisc4==0)
15716 {
15717
2/2
✓ Branch 0 taken 168378 times.
✓ Branch 1 taken 158647 times.
327025 if(loopcnt>0)
15718 {
15719
1/2
✓ Branch 0 taken 168378 times.
✗ Branch 1 not taken.
168378 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc32) - zc::math::Sin(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
15720
1/2
✓ Branch 0 taken 168378 times.
✗ Branch 1 not taken.
168378 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc32) + zc::math::Cos(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
15721 168378 }
15722 else
15723 {
15724 158647 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
15725 158647 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
15726 }
15727
15728 327025 temp_x=guys.spr(i)->x;
15729 327025 temp_y=guys.spr(i)->y;
15730 327025 }
15731 else
15732 {
15733 7259 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
15734 7259 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
15735
15736
2/2
✓ Branch 0 taken 3965 times.
✓ Branch 1 taken 3294 times.
7259 if(loopcnt>0)
15737 {
15738 3965 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
15739
1/2
✓ Branch 0 taken 3965 times.
✗ Branch 1 not taken.
3965 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc2 == 0 ? 1 : dmisc2)))*abs(dmisc32);
15740 3965 }
15741 else
15742 {
15743 3294 guys.spr(i)->x = circle_x;
15744 3294 guys.spr(i)->y = circle_y;
15745 }
15746
15747 7259 temp_x=circle_x;
15748 7259 temp_y=circle_y;
15749 }
15750
15751 double _MSVC2022_tmp1, _MSVC2022_tmp2;
15752 334284 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
15753
15754
4/4
✓ Branch 0 taken 61619 times.
✓ Branch 1 taken 272665 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41746 times.
334284 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
15755 {
15756 41746 guys.spr(i)->dir=l_down;
15757 41746 }
15758
4/4
✓ Branch 0 taken 61607 times.
✓ Branch 1 taken 230931 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41734 times.
292538 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
15759 {
15760 41734 guys.spr(i)->dir=left;
15761 41734 }
15762
4/4
✓ Branch 0 taken 61615 times.
✓ Branch 1 taken 189189 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41742 times.
250804 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
15763 {
15764 41742 guys.spr(i)->dir=l_up;
15765 41742 }
15766
4/4
✓ Branch 0 taken 61631 times.
✓ Branch 1 taken 147431 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41758 times.
209062 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
15767 {
15768 41758 guys.spr(i)->dir=up;
15769 41758 }
15770
4/4
✓ Branch 0 taken 61703 times.
✓ Branch 1 taken 105601 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41830 times.
167304 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
15771 {
15772 41830 guys.spr(i)->dir=r_up;
15773 41830 }
15774
4/4
✓ Branch 0 taken 61697 times.
✓ Branch 1 taken 63777 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41824 times.
125474 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
15775 {
15776 41824 guys.spr(i)->dir=right;
15777 41824 }
15778
4/4
✓ Branch 0 taken 61725 times.
✓ Branch 1 taken 21925 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41852 times.
83650 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
15779 {
15780 41852 guys.spr(i)->dir=r_down;
15781 41852 }
15782 else
15783 {
15784 41798 guys.spr(i)->dir=down;
15785 }
15786
15787 334284 guys.spr(i)->x += x;
15788 334284 guys.spr(i)->y = y-guys.spr(i)->y;
15789
15790
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 334284 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 189016 times.
✓ Branch 5 taken 145268 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 189016 times.
334284 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==2 || dmisc5== 3))
15791 {
15792 /*
15793 if(!(zc_oldrand()&127))
15794 {
15795 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID());
15796 sfx(wpnsfx(wpn),pan(x));
15797 }
15798 */
15799
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
145268 if (((esPatra*)guys.spr(i))->clk5 < 0 && (editorflags & ENEMY_FLAG3))
15800 {
15801 if (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16) ++((esPatra*)guys.spr(i))->clk5;
15802 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
15803 {
15804 if (dmisc5 == 3)
15805 {
15806 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
15807 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+200;
15808 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+160;
15809 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
15810 }
15811 else
15812 {
15813 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
15814 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
15815 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+80;
15816 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
15817 }
15818 }
15819 else
15820 {
15821 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
15822 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+80;
15823 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+40;
15824 else ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
15825 }
15826 }
15827
4/6
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 145268 times.
✓ Branch 4 taken 145268 times.
✓ Branch 5 taken 145268 times.
145268 else if ((dmisc19 || ((esPatra*)guys.spr(i))->clk5) && (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16)) ++((esPatra*)guys.spr(i))->clk5;
15828
1/2
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
145268 if (((esPatra*)guys.spr(i))->clk4 > 0) --((esPatra*)guys.spr(i))->clk4;
15829
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
145268 if (!dmisc25 || (dmisc25 == 1 && !((enemy*)guys.spr(i))->superman) || ((dmisc25 == 2 || dmisc25 == 3) && ((enemy*)guys.spr(i))->superman))
15830 {
15831
1/5
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
145268 switch(dmisc20) //Patra Attack Patterns
15832 {
15833 case 4: //Single one rapidfires
15834 {
15835 if (dofire && i == randeye)
15836 {
15837 ((esPatra*)guys.spr(i))->clk5 = -16;
15838 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) ((esPatra*)guys.spr(i))->clk5 = -48;
15839 ((esPatra*)guys.spr(i))->clk4 = 96;
15840 clk5 = -3;
15841 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
15842 }
15843 if (((esPatra*)guys.spr(i))->clk5 == -16 && (((esPatra*)guys.spr(i))->clk4 % 12) == 0)
15844 {
15845 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15846 sfx(wpnsfx(wpn),pan(x));
15847 }
15848 break;
15849 }
15850 case 3: //Ring
15851 {
15852 if (dofire)
15853 {
15854 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15855 {
15856 ((esPatra*)guys.spr(i))->clk5 = -48;
15857 clk5 = -48;
15858 if (editorflags & ENEMY_FLAG6) clk4 = 64;
15859 }
15860 else
15861 {
15862 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15863 sfx(wpnsfx(wpn),pan(x));
15864 int32_t m=Ewpns.Count()-1;
15865 weapon *ew = (weapon*)(Ewpns.spr(m));
15866
15867 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
15868 ((esPatra*)guys.spr(i))->clk5 = 0;
15869 clk5 = 0;
15870 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15871 }
15872 }
15873 if (((esPatra*)guys.spr(i))->clk5 == -16)
15874 {
15875 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15876 sfx(wpnsfx(wpn),pan(x));
15877 int32_t m=Ewpns.Count()-1;
15878 weapon *ew = (weapon*)(Ewpns.spr(m));
15879
15880 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
15881 }
15882 break;
15883 }
15884 case 2: //one after another
15885 {
15886 if (dofire)
15887 {
15888 ((esPatra*)guys.spr(i))->clk5 = -48 - (12*(i-(index+flycnt+1)));
15889 clk5 = -48 - (12*flycnt2);
15890 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
15891 }
15892 if (((esPatra*)guys.spr(i))->clk5 == -16)
15893 {
15894 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15895 sfx(wpnsfx(wpn),pan(x));
15896 }
15897 break;
15898 }
15899 case 1: //random one eye
15900 {
15901 if (dofire && i == randeye)
15902 {
15903 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15904 {
15905 ((esPatra*)guys.spr(i))->clk5 = -48;
15906 clk5 = -48;
15907 if (editorflags & ENEMY_FLAG6) clk4 = 64;
15908 }
15909 else
15910 {
15911 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15912 sfx(wpnsfx(wpn),pan(x));
15913 ((esPatra*)guys.spr(i))->clk5 = 0;
15914 clk5 = 0;
15915 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15916 }
15917 }
15918 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
15919 {
15920 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15921 sfx(wpnsfx(wpn),pan(x));
15922 }
15923 break;
15924 }
15925 default: //old behavior, all eyes can fire any time
15926 {
15927
3/8
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1155 times.
✓ Branch 5 taken 1155 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
145268 if ((((dmisc18 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
15928
3/6
✓ Branch 0 taken 145268 times.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1155 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147578 (!dmisc18 && !(zc_oldrand()&127))) && (((esPatra*)guys.spr(i))->clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15929
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1155 && ((esPatra*)guys.spr(i))->clk5 >= dmisc19) && (!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
15930 (dmisc20 != 2 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > 48))))
15931 {
15932
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1155 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15933 {
15934 ((esPatra*)guys.spr(i))->clk5 = -48;
15935 if (editorflags & ENEMY_FLAG6) clk4 = 64;
15936 }
15937 else
15938 {
15939 1155 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
15940 1155 sfx(wpnsfx(wpn),pan(x));
15941 1155 ((esPatra*)guys.spr(i))->clk5 = 0;
15942
1/2
✓ Branch 0 taken 1155 times.
✗ Branch 1 not taken.
1155 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15943 }
15944 1155 }
15945
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147578 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
15946 {
15947 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
15948 sfx(wpnsfx(wpn),pan(x));
15949 }
15950 145268 break;
15951 }
15952 }
15953 145268 }
15954 145268 }
15955
15956 }
15957 334429 }
15958 46240 }
15959
15960 160441 adjusted=true;
15961 160441 return enemy::animate(index);
15962 161885 }
15963
15964 249 void ePatra::FirePatraWeapon()
15965 { //.707
15966 249 int32_t xoff = 0;
15967 249 int32_t yoff = 0;
15968
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (SIZEflags & OVERRIDE_HIT_WIDTH)
15969 {
15970 xoff += hxofs;
15971 if (weap_data.override_flags & OVERRIDE_HIT_WIDTH)
15972 xoff += (hit_width / 2) - (weap_data.tilew * 8);
15973 else
15974 xoff += (hit_width / 2) - 8;
15975 }
15976
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
15977 {
15978 yoff += hyofs;
15979 if (weap_data.override_flags & OVERRIDE_HIT_HEIGHT)
15980 yoff += (hit_height / 2) - (weap_data.tileh * 8);
15981 else
15982 yoff += (hit_height / 2) - 8;
15983 }
15984 249 sfx(wpnsfx(wpn),pan(x));
15985 // TODO(crash): check that .add succeeds.
15986
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
249 switch (dmisc28)
15987 {
15988 case patrat8SHOT: //Fire Wizzrobe
15989 case patrat4SHOTDIAG:
15990 case patrat4SHOTRAND:
15991 if (dmisc28 != patrat4SHOTRAND || (zc_oldrand()%2)) //if it's the 4 shot rand type, only let it through half the time. Break is within so it doesn't do both, but if it skips this one it'll always do the other one.
15992 {
15993 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_up,-1, getUID(),false));
15994 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
15995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
15996 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
15997
15998 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_down,-1, getUID(),false));
15999 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16000 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16001 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16002
16003 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_up,-1, getUID(),false));
16004 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16005 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16006 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16007
16008 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_down,-1, getUID(),false));
16009 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16010 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16011 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16012
16013 if (dmisc28 == patrat4SHOTDIAG || dmisc28 == patrat4SHOTRAND) break;
16014 }
16015
16016 [[fallthrough]];
16017 case patrat4SHOTCARD: //Stalfos 3
16018 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,up,-1, getUID(),false));
16019 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16020 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16021 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,down,-1, getUID(),false));
16022 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16023 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16024 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,left,-1, getUID(),false));
16025 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16026 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16027 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,right,-1, getUID(),false));
16028 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16029 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16030 break;
16031
16032 default:
16033 249 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16034
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (dmisc28 == patratBREATH) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle += (zc_rand(20,-20)/100.0)*PI;
16035 249 double anglestore = ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle;
16036
3/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 249 times.
249 if (dmisc28 == patrat1SHOTFAST || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16037
4/8
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 249 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 249 times.
249 if (dmisc28 == patrat3SHOT || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16038 {
16039 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16040 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.46364761;
16041 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16042 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16043 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16044 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.46364761;
16045 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16046 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16047 if (dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16048 {
16049 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16050 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.78539816;
16051 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16052 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16053 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16054 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.78539816;
16055 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16056 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16057 }
16058 }
16059 249 break;
16060
16061 }
16062 249 sfx(wpnsfx(wpn),pan(x));
16063 //+0.46364761
16064 //11.80
16065 249 }
16066
16067 324242 void ePatra::draw(BITMAP *dest)
16068 {
16069 324242 tile=o_tile;
16070 324242 update_enemy_frame();
16071 324242 enemy::draw(dest);
16072 324242 }
16073
16074 int32_t ePatra::defend(int32_t wpnId, int32_t *power, int32_t edef)
16075 {
16076 int32_t ret = enemy::defend(wpnId, power, edef);
16077
16078 if(ret < 0 && (flycnt||flycnt2))
16079 return 0;
16080
16081 return ret;
16082 }
16083
16084 1733 int32_t ePatra::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
16085 {
16086 1733 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
16087
16088
6/6
✓ Branch 0 taken 1613 times.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 779 times.
✓ Branch 3 taken 834 times.
✓ Branch 4 taken 447 times.
✓ Branch 5 taken 332 times.
1733 if(ret < 0 && (flycnt||flycnt2))
16089 1281 return 0;
16090
16091 452 return ret;
16092 1733 }
16093
16094 190 void ePatra::init_size_flags() {
16095 190 SIZEflags = d->SIZEflags;
16096
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
190 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16097
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) { txsz = 2; extend = 3; }
16098 // al_trace("Enemy txsz:%i\n", txsz);
16099
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
190 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = tysz; if (tysz > 1) extend = 3; }
16100
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) { tysz = 2; extend = 3; }
16101
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = hit_width;
16102
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) hit_width = 32;
16103
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = hit_height;
16104
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = hzsz;
16105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = hxofs;
16106
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) hxofs = -8;
16107
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = hyofs;
16108 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)xofs;
16110
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) xofs = -8;
16111
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
16112 {
16113 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
16114 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
16115 }
16116
1/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 else if (dmisc10 == 1) yofs = (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset) - 8;
16117
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if (editorflags & ENEMY_FLAG8) misc = 1;
16118
16119
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)zofs;
16120
16121 190 }
16122
16123 1656 esPatra::esPatra(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk)
16124 1656 {
16125 //cs=8;
16126
1/2
✓ Branch 0 taken 1656 times.
✗ Branch 1 not taken.
1656 setParent(prnt);
16127 1656 item_set=0;
16128 1656 misc=clk;
16129 1656 clk4 = 0;
16130 1656 clk5 = 0;
16131 1656 clk = -((misc*21)>>1)-1;
16132
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1656 times.
✓ Branch 2 taken 1656 times.
✗ Branch 3 not taken.
1656 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16133 1656 hit_width=12;
16134 1656 hit_height=12;
16135 1656 hxofs=2;
16136 1656 hyofs=2;
16137 1656 extend = 0;
16138 1656 txsz = 1;
16139 1656 tysz = 1;
16140 /* //These need to be separate enemy editor fields. This enemy class also its draw altered to correctly support big stuff.
16141 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
16142 int32_t prntSIZEflags = prntenemy->SIZEflags;
16143 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16144 // al_trace("Enemy txsz:%i\n", txsz);
16145 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
16146 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = prntenemy->hxsz;
16147 else
16148 hxsz=12;
16149 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = prntenemy->hysz;
16150 else
16151 hysz=12;
16152 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
16153 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
16154 else
16155 hxofs=2;
16156 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
16157 else hyofs=2;
16158 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16159 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
16160 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
16161 {
16162 yofs = (int32_t)prntenemy->yofs; //This seems to be setting to +48 or something with any value set?! -Z
16163 }
16164
16165 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)prntenemy->zofs;
16166 */
16167 1656 mainguy=count_enemy=false;
16168 1656 bgsfx=-1;
16169 //o_tile=0;
16170
2/4
✓ Branch 0 taken 1656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1656 times.
✗ Branch 3 not taken.
1656 flags &= (~guy_never_return);
16171 1656 deadsfx = WAV_EDEAD;
16172 1656 hitsfx = WAV_EHIT;
16173 1656 isCore = false;
16174 1656 }
16175
16176 1010584 bool esPatra::animate(int32_t index)
16177 {
16178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1010584 times.
1010584 if(switch_hooked) return enemy::animate(index);
16179
2/2
✓ Branch 0 taken 15160 times.
✓ Branch 1 taken 995424 times.
1010584 if(dying)
16180 15160 return Dead(index);
16181
16182 995424 return enemy::animate(index);
16183 1010584 }
16184
16185 2028196 void esPatra::draw(BITMAP *dest)
16186 {
16187
2/2
✓ Branch 0 taken 1721294 times.
✓ Branch 1 taken 306902 times.
2028196 if(get_qr(qr_NEWENEMYTILES))
16188 {
16189 1721294 tile = o_tile+(clk&3);
16190
16191
8/9
✓ Branch 0 taken 214278 times.
✓ Branch 1 taken 217924 times.
✓ Branch 2 taken 215346 times.
✓ Branch 3 taken 215726 times.
✓ Branch 4 taken 213062 times.
✓ Branch 5 taken 214350 times.
✓ Branch 6 taken 215734 times.
✓ Branch 7 taken 214874 times.
✗ Branch 8 not taken.
1721294 switch(dir) //directions get screwed up after 8. *shrug*
16192 {
16193 case up: //u
16194 214278 flip=0;
16195 214278 break;
16196
16197 case down: //d
16198 217924 flip=0;
16199 217924 tile+=4;
16200 217924 break;
16201
16202 case left: //l
16203 215346 flip=0;
16204 215346 tile+=8;
16205 215346 break;
16206
16207 case right: //r
16208 215726 flip=0;
16209 215726 tile+=12;
16210 215726 break;
16211
16212 case l_up: //ul
16213 213062 flip=0;
16214 213062 tile+=20;
16215 213062 break;
16216
16217 case r_up: //ur
16218 214350 flip=0;
16219 214350 tile+=24;
16220 214350 break;
16221
16222 case l_down: //dl
16223 215734 flip=0;
16224 215734 tile+=28;
16225 215734 break;
16226
16227 case r_down: //dr
16228 214874 flip=0;
16229 214874 tile+=32;
16230 214874 break;
16231 }
16232 1721294 }
16233 else
16234 {
16235 306902 tile = o_tile+((clk&2)>>1);
16236 }
16237
16238
2/2
✓ Branch 0 taken 114856 times.
✓ Branch 1 taken 1913340 times.
2028196 if(clk>=0)
16239 1913340 enemy::draw(dest);
16240 2028196 }
16241
16242
16243 102 ePatraBS::ePatraBS(zfix ,zfix ,int32_t Id,int32_t Clk) : enemy((zfix)128,(zfix)48,Id,Clk)
16244 102 {
16245 102 adjusted=false;
16246
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 dir=(zc_oldrand()&7)+8;
16247
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 step=0.25;
16248 102 clk4 = 0;
16249 102 clk5 = 0;
16250 //flycnt=6; flycnt2=0;
16251 102 flycnt=dmisc1;
16252 102 flycnt2=0; // PatraBS doesn't have inner rings!
16253 102 loopcnt=0;
16254
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 init_size_flags();
16255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
16256
16257 //nets+4480;
16258 102 }
16259
16260 35963 bool ePatraBS::animate(int32_t index)
16261 {
16262
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35963 times.
35963 if(switch_hooked) return enemy::animate(index);
16263
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 35723 times.
35963 if(dying)
16264 240 return Dead(index);
16265
16266
2/2
✓ Branch 0 taken 31705 times.
✓ Branch 1 taken 4018 times.
35723 if(clk==0)
16267 {
16268 4018 removearmos(x,y);
16269 4018 }
16270
16271 35723 variable_walk_8(rate,homing,hrate,spw_floater);
16272
16273
2/2
✓ Branch 0 taken 35387 times.
✓ Branch 1 taken 336 times.
35723 if(++clk2>90)
16274 {
16275 336 clk2=0;
16276
16277
2/2
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 159 times.
336 if(loopcnt)
16278 177 --loopcnt;
16279 else
16280 {
16281
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 75 times.
159 if(zc::math::SafeMod(misc, dmisc6)==0)
16282 84 loopcnt=dmisc7;
16283 }
16284
16285 336 ++misc;
16286 336 }
16287
16288 // double size=1;;
16289
2/2
✓ Branch 0 taken 153472 times.
✓ Branch 1 taken 35723 times.
189195 for(int32_t i=index+1; i<index+flycnt+1; i++)
16290 {
16291
2/2
✓ Branch 0 taken 152860 times.
✓ Branch 1 taken 612 times.
153472 if(!adjusted)
16292 {
16293 612 ((enemy*)guys.spr(i))->hp=dmisc3;
16294
16295
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(get_qr(qr_NEWENEMYTILES))
16296 {
16297 612 ((enemy*)guys.spr(i))->o_tile=o_tile+dmisc8;
16298 612 }
16299 else
16300 {
16301 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
16302 }
16303
16304 612 ((enemy*)guys.spr(i))->cs = dmisc9;
16305 612 }
16306
16307
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 153368 times.
153472 if(((enemy*)guys.spr(i))->hp <= 0)
16308 {
16309
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 104 times.
235 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
16310 {
16311 131 guys.swap(j,j+1);
16312 131 }
16313
16314 104 --flycnt;
16315 104 }
16316 else
16317 {
16318 153368 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
16319
1/2
✓ Branch 0 taken 153368 times.
✗ Branch 1 not taken.
153368 double a2 = ((int64_t)clk2-pos2*90/(dmisc1==0?1:dmisc1))*PI/45;
16320 153368 temp_x = zc::math::Cos(a2+PI/2)*45;
16321 153368 temp_y = -zc::math::Sin(a2+PI/2)*45;
16322
16323
2/2
✓ Branch 0 taken 77643 times.
✓ Branch 1 taken 75725 times.
153368 if(loopcnt>0)
16324 {
16325 77643 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*45;
16326
1/2
✓ Branch 0 taken 77643 times.
✗ Branch 1 not taken.
77643 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1==0?1:dmisc1)))*22.5;
16327 77643 }
16328 else
16329 {
16330 75725 guys.spr(i)->x = temp_x;
16331 75725 guys.spr(i)->y = temp_y;
16332 }
16333
16334 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16335 153368 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
16336
16337
4/4
✓ Branch 0 taken 29178 times.
✓ Branch 1 taken 124190 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18812 times.
153368 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16338 {
16339 18812 guys.spr(i)->dir=l_down;
16340 18812 }
16341
4/4
✓ Branch 0 taken 29205 times.
✓ Branch 1 taken 105351 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18839 times.
134556 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16342 {
16343 18839 guys.spr(i)->dir=left;
16344 18839 }
16345
4/4
✓ Branch 0 taken 29168 times.
✓ Branch 1 taken 86549 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18802 times.
115717 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16346 {
16347 18802 guys.spr(i)->dir=l_up;
16348 18802 }
16349
4/4
✓ Branch 0 taken 30509 times.
✓ Branch 1 taken 66406 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 20143 times.
96915 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16350 {
16351 20143 guys.spr(i)->dir=up;
16352 20143 }
16353
4/4
✓ Branch 0 taken 28883 times.
✓ Branch 1 taken 47889 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18517 times.
76772 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16354 {
16355 18517 guys.spr(i)->dir=r_up;
16356 18517 }
16357
4/4
✓ Branch 0 taken 29145 times.
✓ Branch 1 taken 29110 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18779 times.
58255 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16358 {
16359 18779 guys.spr(i)->dir=right;
16360 18779 }
16361
4/4
✓ Branch 0 taken 29358 times.
✓ Branch 1 taken 10118 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18992 times.
39476 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16362 {
16363 18992 guys.spr(i)->dir=r_down;
16364 18992 }
16365 else
16366 {
16367 20484 guys.spr(i)->dir=down;
16368 }
16369
16370 153368 guys.spr(i)->x += x;
16371 153368 guys.spr(i)->y += y;
16372 }
16373 153472 }
16374
16375 35723 adjusted=true;
16376 35723 return enemy::animate(index);
16377 35963 }
16378
16379 72874 void ePatraBS::draw(BITMAP *dest)
16380 {
16381 72874 tile=o_tile;
16382
16383
1/2
✓ Branch 0 taken 72874 times.
✗ Branch 1 not taken.
72874 if(get_qr(qr_NEWENEMYTILES))
16384 {
16385 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16386 72874 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
16387
16388
4/4
✓ Branch 0 taken 27164 times.
✓ Branch 1 taken 45710 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 19146 times.
72874 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16389 {
16390 19146 lookat=l_down;
16391 19146 }
16392
4/4
✓ Branch 0 taken 26316 times.
✓ Branch 1 taken 27412 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 18298 times.
53728 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16393 {
16394 18298 lookat=down;
16395 18298 }
16396
4/4
✓ Branch 0 taken 21642 times.
✓ Branch 1 taken 13788 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 13624 times.
35430 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16397 {
16398 13624 lookat=r_down;
16399 13624 }
16400
4/4
✓ Branch 0 taken 15510 times.
✓ Branch 1 taken 6296 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 7492 times.
21806 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16401 {
16402 7492 lookat=right;
16403 7492 }
16404
4/4
✓ Branch 0 taken 9188 times.
✓ Branch 1 taken 5126 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 1170 times.
14314 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16405 {
16406 1170 lookat=r_up;
16407 1170 }
16408
4/4
✓ Branch 0 taken 8982 times.
✓ Branch 1 taken 4162 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 964 times.
13144 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16409 {
16410 964 lookat=up;
16411 964 }
16412
4/4
✓ Branch 0 taken 9718 times.
✓ Branch 1 taken 2462 times.
✓ Branch 2 taken 1700 times.
✓ Branch 3 taken 8018 times.
12180 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16413 {
16414 1700 lookat=l_up;
16415 1700 }
16416 else
16417 {
16418 10480 lookat=left;
16419 }
16420
16421
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 964 times.
✓ Branch 2 taken 18298 times.
✓ Branch 3 taken 10480 times.
✓ Branch 4 taken 7492 times.
✓ Branch 5 taken 1700 times.
✓ Branch 6 taken 1170 times.
✓ Branch 7 taken 19146 times.
✓ Branch 8 taken 13624 times.
72874 switch(lookat) //directions get screwed up after 8. *shrug*
16422 {
16423 case up: //u
16424 964 flip=0;
16425 964 break;
16426
16427 case down: //d
16428 18298 flip=0;
16429 18298 tile+=8;
16430 18298 break;
16431
16432 case left: //l
16433 10480 flip=0;
16434 10480 tile+=40;
16435 10480 break;
16436
16437 case right: //r
16438 7492 flip=0;
16439 7492 tile+=48;
16440 7492 break;
16441
16442 case l_up: //ul
16443 1700 flip=0;
16444 1700 tile+=80;
16445 1700 break;
16446
16447 case r_up: //ur
16448 1170 flip=0;
16449 1170 tile+=88;
16450 1170 break;
16451
16452 case l_down: //dl
16453 19146 flip=0;
16454 19146 tile+=120;
16455 19146 break;
16456
16457 case r_down: //dr
16458 13624 flip=0;
16459 13624 tile+=128;
16460 13624 break;
16461 }
16462
16463 72874 tile+=(2*(clk&3));
16464 72874 xofs-=8;
16465 72874 yofs-=8;
16466 72874 drawblock(dest,15);
16467 72874 xofs+=8;
16468 72874 yofs+=8;
16469 72874 }
16470 else
16471 {
16472 flip=(clk&1);
16473 xofs-=8;
16474 yofs-=8;
16475 enemy::draw(dest);
16476 xofs+=16;
16477 enemy::draw(dest);
16478 yofs+=16;
16479 enemy::draw(dest);
16480 xofs-=16;
16481 enemy::draw(dest);
16482 xofs+=8;
16483 yofs-=8;
16484 }
16485 72874 }
16486
16487 int32_t ePatraBS::defend(int32_t wpnId, int32_t *power, int32_t edef)
16488 {
16489 int32_t ret = enemy::defend(wpnId, power, edef);
16490
16491 if(ret < 0 && (flycnt||flycnt2))
16492 return 0;
16493
16494 return ret;
16495 }
16496
16497 142 int32_t ePatraBS::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
16498 {
16499 142 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
16500
16501
5/6
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 60 times.
✓ Branch 3 taken 81 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 60 times.
142 if(ret < 0 && (flycnt||flycnt2))
16502 81 return 0;
16503
16504 61 return ret;
16505 142 }
16506
16507 102 void ePatraBS::init_size_flags()
16508 {
16509 102 SIZEflags = d->SIZEflags;
16510
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16511 // al_trace("Enemy txsz:%i\n", txsz);
16512
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
16513
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = d->hxsz;
16514 102 else hit_width = 32;
16515
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = d->hysz;
16516
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = d->hzsz;
16517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
16518 102 else hxofs = -8;
16519
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
16520 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16521
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
16522
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
16523 {
16524 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
16525 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
16526 }
16527
16528
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
16529 102 }
16530
16531 612 esPatraBS::esPatraBS(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk)
16532 612 {
16533 //cs=csBOSS;
16534
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 setParent(prnt);
16535 612 item_set=0;
16536 612 misc=clk;
16537 612 clk = -((misc*21)>>1)-1;
16538 612 clk4 = 0;
16539 612 clk5 = 0;
16540
2/4
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
16541 612 int32_t prntSIZEflags = prntenemy->SIZEflags;
16542
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16543 // al_trace("Enemy txsz:%i\n", txsz);
16544
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
16545
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = prntenemy->hit_width;
16546 612 else hit_width=16;
16547
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = prntenemy->hit_height;
16548 612 else hit_height=16;
16549
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
16550
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if ( (prntSIZEflags&OVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
16551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if ( (prntSIZEflags&OVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
16552 612 else hyofs=2;
16553 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16554
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
16555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_Y_OFFSET) != 0 )
16556 {
16557 yofs = (int32_t)prntenemy->yofs;
16558 }
16559
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 else yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16560
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_Z_OFFSET) != 0 ) prntenemy->zofs = (int32_t)zofs;
16561
16562 612 bgsfx=-1;
16563 612 mainguy=count_enemy=false;
16564 612 deadsfx = WAV_EDEAD;
16565 612 hitsfx = WAV_EHIT;
16566
2/4
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 flags &= ~guy_never_return;
16567 612 isCore = false;
16568 612 }
16569
16570 155090 bool esPatraBS::animate(int32_t index)
16571 {
16572
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 155090 times.
155090 if(switch_hooked) return enemy::animate(index);
16573
2/2
✓ Branch 0 taken 1552 times.
✓ Branch 1 taken 153538 times.
155090 if(dying)
16574 1552 return Dead(index);
16575
16576 153538 return enemy::animate(index);
16577 155090 }
16578
16579 315868 void esPatraBS::draw(BITMAP *dest)
16580 {
16581 315868 tile=o_tile;
16582
16583
1/2
✓ Branch 0 taken 315868 times.
✗ Branch 1 not taken.
315868 if(get_qr(qr_NEWENEMYTILES))
16584 {
16585
8/9
✓ Branch 0 taken 41612 times.
✓ Branch 1 taken 42622 times.
✓ Branch 2 taken 37916 times.
✓ Branch 3 taken 38458 times.
✓ Branch 4 taken 38564 times.
✓ Branch 5 taken 38568 times.
✓ Branch 6 taken 38662 times.
✓ Branch 7 taken 39466 times.
✗ Branch 8 not taken.
315868 switch(dir) //directions get screwed up after 8. *shrug*
16586 {
16587 case up: //u
16588 41612 flip=0;
16589 41612 break;
16590
16591 case down: //d
16592 42622 flip=0;
16593 42622 tile+=4;
16594 42622 break;
16595
16596 case left: //l
16597 37916 flip=0;
16598 37916 tile+=8;
16599 37916 break;
16600
16601 case right: //r
16602 38458 flip=0;
16603 38458 tile+=12;
16604 38458 break;
16605
16606 case l_up: //ul
16607 38564 flip=0;
16608 38564 tile+=20;
16609 38564 break;
16610
16611 case r_up: //ur
16612 38568 flip=0;
16613 38568 tile+=24;
16614 38568 break;
16615
16616 case l_down: //dl
16617 38662 flip=0;
16618 38662 tile+=28;
16619 38662 break;
16620
16621 case r_down: //dr
16622 39466 flip=0;
16623 39466 tile+=32;
16624 39466 break;
16625 }
16626
16627 315868 tile += ((clk&6)>>1);
16628 315868 }
16629 else
16630 {
16631 tile += (clk&4)?1:0;
16632 }
16633
16634
2/2
✓ Branch 0 taken 32116 times.
✓ Branch 1 taken 283752 times.
315868 if(clk>=0)
16635 283752 enemy::draw(dest);
16636 315868 }
16637
16638 257618 void addEwpn(int32_t x,int32_t y,int32_t z,int32_t id,int32_t type,int32_t power,int32_t dir, int32_t parentid, byte script_generated, int32_t fakez)
16639 {
16640
4/6
✓ Branch 0 taken 150748 times.
✓ Branch 1 taken 106870 times.
✓ Branch 2 taken 150748 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 150748 times.
✗ Branch 5 not taken.
257618 if(id>wEnemyWeapons || (id >= wScript1 && id <= wScript10))
16641
4/8
✓ Branch 0 taken 257618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 257618 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 257618 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 257618 times.
✗ Branch 7 not taken.
257618 Ewpns.add(new weapon((zfix)x,(zfix)y,(zfix)z,id,type,power,dir, -1, parentid, script_generated));
16642
1/2
✓ Branch 0 taken 257618 times.
✗ Branch 1 not taken.
257618 if (fakez > 0) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16643 257618 }
16644
16645 74710 int32_t hit_enemy(int32_t index, int32_t wpnId,int32_t power,int32_t wpnx,int32_t wpny,int32_t dir, int32_t enemyHitWeapon, weapon* realweap)
16646 {
16647 // Kludge
16648
4/8
✓ Branch 0 taken 74710 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 74710 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 74710 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 74710 times.
✗ Branch 7 not taken.
74710 weapon *w = new weapon((zfix)wpnx,(zfix)wpny,(zfix)0,wpnId,0,power,dir,enemyHitWeapon,-1,false);
16649 74710 int32_t ret = ((enemy*)guys.spr(index))->takehit(w,realweap);
16650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74710 times.
74710 delete w;
16651 74710 return ret;
16652 }
16653
16654 9214 void enemy_scored(int32_t index)
16655 {
16656 9214 ((enemy*)guys.spr(index))->scored=true;
16657 9214 }
16658
16659 2191 void addguy(int32_t x,int32_t y,int32_t id,int32_t clk,bool mainguy,mapscr* parentscr)
16660 {
16661
5/8
✓ Branch 0 taken 2191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2191 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 279 times.
✓ Branch 5 taken 1912 times.
✓ Branch 6 taken 2191 times.
✗ Branch 7 not taken.
2191 guy *g = new guy((zfix)x,(zfix)y,id,get_qr(qr_NOGUYPOOF)?0:clk,mainguy);
16662
2/2
✓ Branch 0 taken 1426 times.
✓ Branch 1 taken 765 times.
2191 if (isdungeon(g->screen_spawned))
16663 765 g->y += 1;
16664
5/6
✓ Branch 0 taken 1277 times.
✓ Branch 1 taken 914 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1273 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
2191 if(parentscr && parentscr->guytile > -1 && !get_qr(qr_OLD_GUY_HANDLING))
16665 {
16666 4 g->o_tile = parentscr->guytile;
16667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(g->o_tile != 0)
16668 4 g->flags &= ~guy_invisible;
16669 4 g->cs = parentscr->guycs;
16670 4 }
16671 2191 guys.add(g);
16672 2191 }
16673
16674 23701 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup)
16675 {
16676
4/8
✓ Branch 0 taken 23701 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23701 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23701 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 23701 times.
✗ Branch 7 not taken.
23701 item *i = new item(zfix(x), zfix(y - get_qr(qr_NOITEMOFFSET)), 0_zf, id, pickup, 0);
16677 23701 items.add(i);
16678 23701 }
16679
16680 150 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup,int32_t clk)
16681 {
16682
5/10
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 150 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 150 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 150 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 150 times.
✗ Branch 9 not taken.
150 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,clk);
16683 150 items.add(i);
16684 150 }
16685
16686 3 void adddummyitem(int32_t x,int32_t y,int32_t id,int32_t pickup)
16687 {
16688
5/10
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
3 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,0,true);
16689 3 items.add(i);
16690 3 }
16691
16692 19326 void add_item_for_screen(int32_t screen, item* item)
16693 {
16694 19326 item->screen_spawned = screen;
16695 19326 items.add(item);
16696 19326 }
16697
16698 96 void kill_em_all()
16699 {
16700
2/2
✓ Branch 0 taken 353 times.
✓ Branch 1 taken 96 times.
449 for(int32_t i=0; i<guys.Count(); i++)
16701 {
16702 353 enemy *e = ((enemy*)guys.spr(i));
16703
16704
3/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 323 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
353 if(e->flags&(1<<3) && !(e->type == eeGHINI && e->dmisc1 == 1)) continue;
16705
16706 323 e->kickbucket();
16707 323 }
16708 96 }
16709
16710 bool can_kill_em_all()
16711 {
16712 for(int32_t i=0; i<guys.Count(); i++)
16713 {
16714 enemy *e = ((enemy*)guys.spr(i));
16715
16716 if(e->flags&(1<<3) && !(e->type == eeGHINI && e->dmisc1 == 1)) continue;
16717 if(e->superman) continue;
16718 return true;
16719 }
16720 return false;
16721 }
16722
16723 //This needs a quest rule, or enemy flag, Dying Enemy Doesn't Hurt Hero
16724 // For Hero's hit detection. Don't count them if they are stunned or are guys.
16725 int32_t GuyHit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
16726 {
16727 for(int32_t i=0; i<guys.Count(); i++)
16728 {
16729 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
16730 {
16731 if(((enemy*)guys.spr(i))->stunclk==0 && ((enemy*)guys.spr(i))->frozenclock==0 && (!get_qr(qr_SAFEENEMYFADE) || ((enemy*)guys.spr(i))->fading != fade_flicker)
16732 &&(((enemy*)guys.spr(i))->d->type != eeGUY || ((enemy*)guys.spr(i))->dmisc1))
16733 {
16734 return i;
16735 }
16736 }
16737 }
16738
16739 return -1;
16740 }
16741
16742 13157767 int32_t GuyHitFrom(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
16743 {
16744
4/4
✓ Branch 0 taken 16511 times.
✓ Branch 1 taken 13141256 times.
✓ Branch 2 taken 33818802 times.
✓ Branch 3 taken 13126788 times.
46945590 for(int32_t i=zc_max(0, index); i<guys.Count(); i++)
16745 {
16746
2/2
✓ Branch 0 taken 30979 times.
✓ Branch 1 taken 33787823 times.
33818802 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
16747 {
16748 30979 return i;
16749 }
16750 33787823 }
16751
16752 13126788 return -1;
16753 13157767 }
16754
16755 // For Hero's hit detection. Count them if they are dying.
16756 52508 int32_t GuyHit(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
16757 {
16758 52508 enemy *e = (enemy*)guys.spr(index);
16759
3/4
✓ Branch 0 taken 52508 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28055 times.
✓ Branch 3 taken 24453 times.
52508 if(!e || e->hp > 0)
16760 28055 return -1;
16761
16762 24453 bool d = e->dying;
16763 24453 int32_t hc = e->hclk;
16764 24453 e->dying = false;
16765 24453 e->hclk = 0;
16766 24453 bool hit = e->hit(tx,ty,tz,txsz,tysz,tzsz);
16767 24453 e->dying = d;
16768 24453 e->hclk = hc;
16769
16770
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 24296 times.
24453 return hit ? index : -1;
16771 52508 }
16772
16773 14675165 bool hasMainGuy(int screen)
16774 {
16775
2/2
✓ Branch 0 taken 15979810 times.
✓ Branch 1 taken 5951056 times.
21930866 for(int32_t i=0; i<guys.Count(); i++)
16776 {
16777 15979810 enemy* e = (enemy*)guys.spr(i);
16778
4/4
✓ Branch 0 taken 15516726 times.
✓ Branch 1 taken 463084 times.
✓ Branch 2 taken 8724109 times.
✓ Branch 3 taken 6792617 times.
15979810 if (e->screen_spawned == screen && e->mainguy)
16779 {
16780 8724109 return true;
16781 }
16782 7255701 }
16783
16784 5951056 return false;
16785 14675165 }
16786
16787 138 void EatHero(int32_t index)
16788 {
16789 138 ((eStalfos*)guys.spr(index))->eathero();
16790 138 }
16791
16792 9 void GrabHero(int32_t index)
16793 {
16794 9 ((eWallM*)guys.spr(index))->grabhero();
16795 9 }
16796
16797 1338 bool CarryHero()
16798 {
16799
1/2
✓ Branch 0 taken 3933 times.
✗ Branch 1 not taken.
3933 for(int32_t i=0; i<guys.Count(); i++)
16800 {
16801
2/2
✓ Branch 0 taken 2090 times.
✓ Branch 1 taken 1843 times.
3933 if(((guy*)(guys.spr(i)))->type==eeWALLM)
16802 {
16803
2/2
✓ Branch 0 taken 1338 times.
✓ Branch 1 taken 505 times.
1843 if(((eWallM*)guys.spr(i))->hashero)
16804 {
16805 1338 Hero.x=guys.spr(i)->x;
16806 1338 Hero.y=guys.spr(i)->y;
16807 1338 return ((eWallM*)guys.spr(i))->misc > 0;
16808 }
16809 505 }
16810
16811 // Like Likes currently can't carry Hero.
16812 /*
16813 if(((guy*)(guys.spr(i)))->family==eeLIKE)
16814 {
16815 if(((eLikeLike*)guys.spr(i))->hashero)
16816 {
16817 Hero.x=guys.spr(i)->x;
16818 Hero.y=guys.spr(i)->y;
16819 return (true);
16820 }
16821 }*/
16822 2595 }
16823
16824 return false;
16825 1338 }
16826
16827 // Move item with guy
16828 void movefairy(zfix &x,zfix &y,int32_t misc)
16829 {
16830 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
16831
16832 if(i!=-1)
16833 {
16834 x = guys.spr(i)->x;
16835 y = guys.spr(i)->y;
16836 }
16837 }
16838
16839 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
16840 void movefairy2(zfix x,zfix y,int32_t misc)
16841 {
16842 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
16843
16844 if(i!=-1)
16845 {
16846 guys.spr(i)->x = x;
16847 guys.spr(i)->y = y;
16848 }
16849 }// Move item with guy
16850
16851 60788 void movefairynew(zfix &x,zfix &y, item const &itemfairy)
16852 {
16853 60788 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
16854
16855
1/2
✓ Branch 0 taken 60788 times.
✗ Branch 1 not taken.
60788 if(fairy)
16856 {
16857 60788 x = fairy->x;
16858 60788 y = fairy->y;
16859 60788 }
16860 60788 }
16861
16862 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
16863 404 void movefairynew2(zfix x,zfix y, item const &itemfairy)
16864 {
16865 404 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
16866
16867
1/2
✓ Branch 0 taken 404 times.
✗ Branch 1 not taken.
404 if(fairy)
16868 {
16869 404 fairy->x = x;
16870 404 fairy->y = y;
16871 404 }
16872 404 }
16873
16874 void killfairy(int32_t misc)
16875 {
16876 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
16877 guys.del(i);
16878 }
16879
16880 219 int32_t getGuyIndex(const int32_t eid)
16881 {
16882
1/2
✓ Branch 0 taken 828 times.
✗ Branch 1 not taken.
828 for(word i = 0; i < guys.Count(); i++)
16883 {
16884
2/2
✓ Branch 0 taken 219 times.
✓ Branch 1 taken 609 times.
828 if(guys.spr(i)->getUID() == eid)
16885 219 return i;
16886 609 }
16887
16888 return -1;
16889 219 }
16890
16891 219 void killfairynew(item const &itemfairy)
16892 {
16893 219 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
16894
1/2
✓ Branch 0 taken 219 times.
✗ Branch 1 not taken.
219 if (fairy != NULL) guys.del(getGuyIndex(itemfairy.fairyUID));
16895 219 }
16896
16897 //Should probably change this to return an 'enemy*', null on failure -Em
16898 21822 int32_t addenemy(int32_t screen, int32_t x,int32_t y,int32_t id,int32_t clk)
16899 {
16900 21822 return addenemy_z(screen,x,y,0,id,clk);
16901 }
16902
16903 1965 int32_t addchild(int32_t screen, int32_t x,int32_t y,int32_t id,int32_t clk, sprite* parent)
16904 {
16905 1965 return addchild_z(screen,x,y,0,id,clk, parent);
16906 }
16907
16908 1997 int32_t addchild_z(int32_t screen, int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk, sprite* parent)
16909 {
16910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1997 times.
1997 if(id <= 0) return 0;
16911
16912 1997 int32_t ret = 0;
16913 1997 sprite *e=NULL;
16914
16915
6/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1865 times.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 2 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 4 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
1997 switch(guysbuf[id&0xFFF].type)
16916 {
16917 //Fixme: possible enemy memory leak. (minor)
16918 case eeWALK:
16919
3/6
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 110 times.
✗ Branch 5 not taken.
110 e = new eStalfos((zfix)x,(zfix)y,id,clk);
16920 110 break;
16921
16922 case eeLEV:
16923 e = new eLeever((zfix)x,(zfix)y,id,clk);
16924 break;
16925
16926 case eeTEK:
16927 e = new eTektite((zfix)x,(zfix)y,id,clk);
16928 break;
16929
16930 case eePEAHAT:
16931 e = new ePeahat((zfix)x,(zfix)y,id,clk);
16932 break;
16933
16934 case eeZORA:
16935 e = new eZora((zfix)x,(zfix)y,id,clk);
16936 break;
16937
16938 case eeGHINI:
16939 e = new eGhini((zfix)x,(zfix)y,id,clk);
16940 break;
16941
16942 case eeKEESE:
16943
3/6
✓ Branch 0 taken 1865 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1865 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1865 times.
✗ Branch 5 not taken.
1865 e = new eKeese((zfix)x,(zfix)y,id,clk);
16944 1865 break;
16945
16946 case eeWIZZ:
16947
3/6
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
15 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
16948 15 break;
16949
16950 case eePROJECTILE:
16951 e = new eProjectile((zfix)x,(zfix)y,id,clk);
16952 break;
16953
16954 case eeWALLM:
16955 e = new eWallM((zfix)x,(zfix)y,id,clk);
16956 break;
16957
16958 case eeAQUA:
16959 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
16960 break;
16961
16962 case eeMOLD:
16963 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
16964 break;
16965
16966 case eeMANHAN:
16967
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 e = new eManhandla((zfix)x,(zfix)y,id,clk);
16968 1 break;
16969
16970 case eeGLEEOK:
16971 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
16972 break;
16973
16974 case eeGHOMA:
16975 e = new eGohma((zfix)x,(zfix)y,id,clk);
16976 break;
16977
16978 case eeLANM:
16979 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])));
16980 break;
16981
16982 case eeGANON:
16983 e = new eGanon((zfix)x,(zfix)y,id,clk);
16984 break;
16985
16986 case eeFAIRY:
16987 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
16988 break;
16989
16990 case eeFIRE:
16991
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 e = new eFire((zfix)x,(zfix)y,id,clk);
16992 2 break;
16993
16994 case eeOTHER:
16995 e = new eOther((zfix)x,(zfix)y,id,clk);
16996 break;
16997
16998
16999 case eeSCRIPT01:
17000 case eeSCRIPT02:
17001 case eeSCRIPT03:
17002 case eeSCRIPT04:
17003 case eeSCRIPT05:
17004 case eeSCRIPT06:
17005 case eeSCRIPT07:
17006 case eeSCRIPT08:
17007 case eeSCRIPT09:
17008 case eeSCRIPT10:
17009 case eeSCRIPT11:
17010 case eeSCRIPT12:
17011 case eeSCRIPT13:
17012 case eeSCRIPT14:
17013 case eeSCRIPT15:
17014 case eeSCRIPT16:
17015 case eeSCRIPT17:
17016 case eeSCRIPT18:
17017 case eeSCRIPT19:
17018 case eeSCRIPT20:
17019 {
17020 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17021 {
17022 e = new eScript((zfix)x,(zfix)y,id,clk);
17023 break;
17024 }
17025 else return 0;
17026 }
17027
17028 case eeFFRIENDLY01:
17029 case eeFFRIENDLY02:
17030 case eeFFRIENDLY03:
17031 case eeFFRIENDLY04:
17032 case eeFFRIENDLY05:
17033 case eeFFRIENDLY06:
17034 case eeFFRIENDLY07:
17035 case eeFFRIENDLY08:
17036 case eeFFRIENDLY09:
17037 case eeFFRIENDLY10:
17038 {
17039 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17040 {
17041 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
17042 }
17043 else return 0;
17044
17045 }
17046
17047 case eeSPINTILE:
17048 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
17049 break;
17050
17051 // and these enemies use the misc10/misc2 value
17052 case eeROCK:
17053 {
17054 switch(guysbuf[id&0xFFF].attributes[9])
17055 {
17056 case 1:
17057 e = new eBoulder((zfix)x,(zfix)y,id,clk);
17058 break;
17059
17060 case 0:
17061 default:
17062 e = new eRock((zfix)x,(zfix)y,id,clk);
17063 break;
17064 }
17065
17066 break;
17067 }
17068
17069 case eeTRAP:
17070 {
17071 switch(guysbuf[id&0xFFF].attributes[1])
17072 {
17073 case 1:
17074 e = new eTrap2((zfix)x,(zfix)y,id,clk);
17075 break;
17076
17077 case 0:
17078 default:
17079 e = new eTrap((zfix)x,(zfix)y,id,clk);
17080 break;
17081 }
17082
17083 break;
17084 }
17085
17086 case eeDONGO:
17087 {
17088 switch(guysbuf[id&0xFFF].attributes[9])
17089 {
17090 case 1:
17091 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
17092 break;
17093
17094 case 0:
17095 default:
17096 e = new eDodongo((zfix)x,(zfix)y,id,clk);
17097 break;
17098 }
17099
17100 break;
17101 }
17102
17103 case eeDIG:
17104 {
17105
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 switch(guysbuf[id&0xFFF].attributes[9])
17106 {
17107 case 1:
17108 e = new eLilDig((zfix)x,(zfix)y,id,clk);
17109 break;
17110
17111 4 case 0:
17112 default:
17113
3/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 e = new eBigDig((zfix)x,(zfix)y,id,clk);
17114 4 break;
17115 }
17116
17117 4 break;
17118 }
17119
17120 case eePATRA:
17121 {
17122 switch(guysbuf[id&0xFFF].attributes[9])
17123 {
17124 case 1:
17125 if (get_qr(qr_HARDCODED_BS_PATRA))
17126 {
17127 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
17128 break;
17129 }
17130 [[fallthrough]];
17131 case 0:
17132 default:
17133 e = new ePatra((zfix)x,(zfix)y,id,clk);
17134 break;
17135 }
17136
17137 break;
17138 }
17139
17140 case eeGUY:
17141 {
17142 switch(guysbuf[id&0xFFF].attributes[9])
17143 {
17144 case 1:
17145 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17146 break;
17147
17148 case 0:
17149 default:
17150 e = new eNPC((zfix)x,(zfix)y,id,clk);
17151 break;
17152 }
17153
17154 break;
17155 }
17156
17157 case eeNONE:
17158 if(guysbuf[id&0xFFF].attributes[9] ==1)
17159 {
17160 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17161 break;
17162 break;
17163 }
17164 [[fallthrough]];
17165 default:
17166
17167 return 0;
17168 }
17169
17170 1997 ret++; // Made one enemy.
17171
17172
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1990 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
1997 if(z && canfall(id))
17173 {
17174 7 e->z = (zfix)z;
17175 7 }
17176
17177
2/2
✓ Branch 0 taken 1990 times.
✓ Branch 1 taken 7 times.
1997 ((enemy*)e)->ceiling = (z && canfall(id));
17178 1997 e->setParent(parent);
17179
17180
1/2
✓ Branch 0 taken 1997 times.
✗ Branch 1 not taken.
1997 if(!guys.add(e))
17181 {
17182 return 0;
17183 }
17184
17185 // add segments of segmented enemies
17186 1997 int32_t c=0;
17187
17188
2/6
✓ Branch 0 taken 1996 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1997 switch(guysbuf[id&0xFFF].type)
17189 {
17190 case eeMOLD:
17191 {
17192 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17193 id &= 0xFFF;
17194
17195 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].attributes[0])); i++)
17196 {
17197 //christ this is messy -DD
17198 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
17199
17200 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
17201 {
17202 al_trace("Moldorm segment %d could not be created!\n",i+1);
17203
17204 for(int32_t j=0; j<i+1; j++)
17205 guys.del(guys.Count()-1);
17206
17207 return 0;
17208 }
17209
17210 if(i>0)
17211 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17212
17213 ret++;
17214 }
17215
17216 break;
17217 }
17218
17219 case eeLANM:
17220 {
17221 id &= 0xFFF;
17222 int32_t shft = guysbuf[id].attributes[1];
17223 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17224
17225 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
17226 {
17227 al_trace("Lanmola segment 1 could not be created!\n");
17228 guys.del(guys.Count()-1);
17229 return 0;
17230 }
17231
17232 ret++;
17233
17234 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])); i++)
17235 {
17236 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
17237 {
17238 al_trace("Lanmola segment %d could not be created!\n",i+1);
17239
17240 for(int32_t j=0; j<i+1; j++)
17241 guys.del(guys.Count()-1);
17242
17243 return 0;
17244 }
17245
17246 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17247 ret++;
17248 }
17249 }
17250 break;
17251
17252 case eeMANHAN:
17253 1 id &= 0xFFF;
17254
17255
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<((!(guysbuf[id].attributes[1]))?4:8); i++)
17256 {
17257
4/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
4 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
17258 {
17259 al_trace("Manhandla head %d could not be created!\n",i+1);
17260
17261 for(int32_t j=0; j<i+1; j++)
17262 {
17263 guys.del(guys.Count()-1);
17264 }
17265
17266 return 0;
17267 }
17268
17269 4 ret++;
17270 4 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].attributes[0];
17271 4 }
17272
17273 1 break;
17274
17275 case eeGLEEOK:
17276 {
17277 id &= 0xFFF;
17278
17279 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])); i++)
17280 {
17281 if(!guys.add(new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e)))
17282 {
17283 al_trace("Gleeok head %d could not be created!\n",i+1);
17284
17285 for(int32_t j=0; j<i+1; j++)
17286 {
17287 guys.del(guys.Count()-1);
17288 }
17289
17290 return false;
17291 }
17292
17293 c-=guysbuf[id].attributes[3];
17294 ret++;
17295 }
17296 }
17297 break;
17298
17299
17300 case eePATRA:
17301 {
17302 id &= 0xFFF;
17303 int32_t outeyes = 0;
17304
17305 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[0]); i++)
17306 {
17307 if(!((guysbuf[id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
17308 {
17309 al_trace("Patra outer eye %d could not be created!\n",i+1);
17310
17311 for(int32_t j=0; j<i+1; j++)
17312 guys.del(guys.Count()-1);
17313
17314 return 0;
17315 }
17316 else
17317 outeyes++;
17318
17319 ret++;
17320 }
17321
17322 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[1]); i++)
17323 {
17324 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
17325 {
17326 al_trace("Patra inner eye %d could not be created!\n",i+1);
17327
17328 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
17329 guys.del(guys.Count()-1);
17330
17331 return 0;
17332 }
17333
17334 ret++;
17335 }
17336
17337 break;
17338 }
17339 }
17340
17341
2/2
✓ Branch 0 taken 2001 times.
✓ Branch 1 taken 1997 times.
3998 for (int i = 0; i < ret; i++)
17342 {
17343 2001 enemy* e = (enemy*)guys.spr(guys.Count() - 1 - i);
17344 2001 e->screen_spawned = screen;
17345 2001 }
17346
17347 1997 return ret;
17348 1997 }
17349
17350 // Returns number of enemies/segments created
17351 102142 int32_t addenemy_z(int32_t screen,int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk)
17352 {
17353 102142 int32_t realid = id&0xFFF;
17354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102142 times.
102142 if( realid > MAXGUYS )
17355 {
17356 return 0;
17357 }
17358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102142 times.
102142 if(id <= 0) return 0;
17359
17360 102142 int32_t ret = 0;
17361 102142 sprite *e=NULL;
17362
17363
28/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 50147 times.
✓ Branch 4 taken 3942 times.
✓ Branch 5 taken 5212 times.
✓ Branch 6 taken 1825 times.
✓ Branch 7 taken 2797 times.
✓ Branch 8 taken 461 times.
✓ Branch 9 taken 11855 times.
✓ Branch 10 taken 5335 times.
✓ Branch 11 taken 4429 times.
✓ Branch 12 taken 998 times.
✓ Branch 13 taken 126 times.
✓ Branch 14 taken 618 times.
✓ Branch 15 taken 149 times.
✓ Branch 16 taken 168 times.
✓ Branch 17 taken 93 times.
✓ Branch 18 taken 420 times.
✓ Branch 19 taken 13 times.
✓ Branch 20 taken 732 times.
✓ Branch 21 taken 758 times.
✓ Branch 22 taken 7630 times.
✓ Branch 23 taken 94 times.
✓ Branch 24 taken 384 times.
✓ Branch 25 taken 2472 times.
✓ Branch 26 taken 251 times.
✓ Branch 27 taken 403 times.
✓ Branch 28 taken 292 times.
✓ Branch 29 taken 5 times.
✓ Branch 30 taken 533 times.
102142 switch(guysbuf[id&0xFFF].type)
17364 {
17365 //Fixme: possible enemy memory leak. (minor)
17366 case eeWALK:
17367
3/6
✓ Branch 0 taken 50147 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50147 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50147 times.
✗ Branch 5 not taken.
50147 e = new eStalfos((zfix)x,(zfix)y,id,clk);
17368 50147 break;
17369
17370 case eeLEV:
17371
3/6
✓ Branch 0 taken 3942 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3942 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3942 times.
✗ Branch 5 not taken.
3942 e = new eLeever((zfix)x,(zfix)y,id,clk);
17372 3942 break;
17373
17374 case eeTEK:
17375
3/6
✓ Branch 0 taken 5212 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5212 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5212 times.
✗ Branch 5 not taken.
5212 e = new eTektite((zfix)x,(zfix)y,id,clk);
17376 5212 break;
17377
17378 case eePEAHAT:
17379
3/6
✓ Branch 0 taken 1825 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1825 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1825 times.
✗ Branch 5 not taken.
1825 e = new ePeahat((zfix)x,(zfix)y,id,clk);
17380 1825 break;
17381
17382 case eeZORA:
17383
3/6
✓ Branch 0 taken 2797 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2797 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2797 times.
✗ Branch 5 not taken.
2797 e = new eZora((zfix)x,(zfix)y,id,clk);
17384 2797 break;
17385
17386 case eeGHINI:
17387
3/6
✓ Branch 0 taken 461 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 461 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 461 times.
✗ Branch 5 not taken.
461 e = new eGhini((zfix)x,(zfix)y,id,clk);
17388 461 break;
17389
17390 case eeKEESE:
17391
3/6
✓ Branch 0 taken 11855 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11855 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11855 times.
✗ Branch 5 not taken.
11855 e = new eKeese((zfix)x,(zfix)y,id,clk);
17392 11855 break;
17393
17394 case eeWIZZ:
17395
3/6
✓ Branch 0 taken 5335 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5335 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5335 times.
✗ Branch 5 not taken.
5335 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
17396 5335 break;
17397
17398 case eePROJECTILE:
17399
3/6
✓ Branch 0 taken 4429 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4429 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4429 times.
✗ Branch 5 not taken.
4429 e = new eProjectile((zfix)x,(zfix)y,id,clk);
17400 4429 break;
17401
17402 case eeWALLM:
17403
3/6
✓ Branch 0 taken 998 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 998 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 998 times.
✗ Branch 5 not taken.
998 e = new eWallM((zfix)x,(zfix)y,id,clk);
17404 998 break;
17405
17406 case eeAQUA:
17407
3/6
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 126 times.
✗ Branch 5 not taken.
126 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
17408 126 break;
17409
17410 case eeMOLD:
17411
6/12
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 618 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 618 times.
✓ Branch 6 taken 618 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 618 times.
✓ Branch 10 taken 618 times.
✗ Branch 11 not taken.
618 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17412 618 break;
17413
17414 case eeMANHAN:
17415
3/6
✓ Branch 0 taken 149 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 149 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 149 times.
✗ Branch 5 not taken.
149 e = new eManhandla((zfix)x,(zfix)y,id,clk);
17416 149 break;
17417
17418 case eeGLEEOK:
17419
7/12
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 168 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 168 times.
✓ Branch 6 taken 152 times.
✓ Branch 7 taken 16 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 152 times.
✓ Branch 10 taken 168 times.
✗ Branch 11 not taken.
168 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17420 168 break;
17421
17422 case eeGHOMA:
17423
3/6
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93 times.
✗ Branch 5 not taken.
93 e = new eGohma((zfix)x,(zfix)y,id,clk);
17424 93 break;
17425
17426 case eeLANM:
17427
6/12
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 420 times.
✓ Branch 6 taken 420 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 420 times.
✓ Branch 10 taken 420 times.
✗ Branch 11 not taken.
420 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])));
17428 420 break;
17429
17430 case eeGANON:
17431
3/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
13 e = new eGanon((zfix)x,(zfix)y,id,clk);
17432 13 break;
17433
17434 case eeFAIRY:
17435
3/6
✓ Branch 0 taken 732 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 732 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 732 times.
✗ Branch 5 not taken.
732 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
17436 732 break;
17437
17438 case eeFIRE:
17439
3/6
✓ Branch 0 taken 758 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 758 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 758 times.
✗ Branch 5 not taken.
758 e = new eFire((zfix)x,(zfix)y,id,clk);
17440 758 break;
17441
17442 case eeOTHER:
17443
3/6
✓ Branch 0 taken 7630 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7630 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7630 times.
✗ Branch 5 not taken.
7630 e = new eOther((zfix)x,(zfix)y,id,clk);
17444 7630 break;
17445
17446
17447 case eeSCRIPT01:
17448 case eeSCRIPT02:
17449 case eeSCRIPT03:
17450 case eeSCRIPT04:
17451 case eeSCRIPT05:
17452 case eeSCRIPT06:
17453 case eeSCRIPT07:
17454 case eeSCRIPT08:
17455 case eeSCRIPT09:
17456 case eeSCRIPT10:
17457 case eeSCRIPT11:
17458 case eeSCRIPT12:
17459 case eeSCRIPT13:
17460 case eeSCRIPT14:
17461 case eeSCRIPT15:
17462 case eeSCRIPT16:
17463 case eeSCRIPT17:
17464 case eeSCRIPT18:
17465 case eeSCRIPT19:
17466 case eeSCRIPT20:
17467 {
17468 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17469 {
17470 e = new eScript((zfix)x,(zfix)y,id,clk);
17471 break;
17472 }
17473 else return 0;
17474 }
17475
17476 case eeFFRIENDLY01:
17477 case eeFFRIENDLY02:
17478 case eeFFRIENDLY03:
17479 case eeFFRIENDLY04:
17480 case eeFFRIENDLY05:
17481 case eeFFRIENDLY06:
17482 case eeFFRIENDLY07:
17483 case eeFFRIENDLY08:
17484 case eeFFRIENDLY09:
17485 case eeFFRIENDLY10:
17486 {
17487 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17488 {
17489 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
17490 }
17491 else return 0;
17492
17493 }
17494
17495 case eeSPINTILE:
17496
3/6
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 94 times.
✗ Branch 5 not taken.
94 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
17497 94 break;
17498
17499 // and these enemies use the misc10/misc2 value
17500 case eeROCK:
17501 {
17502
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 354 times.
384 switch(guysbuf[id&0xFFF].attributes[9])
17503 {
17504 case 1:
17505
3/6
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
30 e = new eBoulder((zfix)x,(zfix)y,id,clk);
17506 30 break;
17507
17508 354 case 0:
17509 default:
17510
3/6
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 354 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 354 times.
✗ Branch 5 not taken.
354 e = new eRock((zfix)x,(zfix)y,id,clk);
17511 354 break;
17512 }
17513
17514 384 break;
17515 }
17516
17517 case eeTRAP:
17518 {
17519
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✓ Branch 2 taken 1640 times.
2472 switch(guysbuf[id&0xFFF].attributes[1])
17520 {
17521 case 1:
17522
3/6
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 832 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 832 times.
✗ Branch 5 not taken.
832 e = new eTrap2((zfix)x,(zfix)y,id,clk);
17523 832 break;
17524
17525 1640 case 0:
17526 default:
17527
3/6
✓ Branch 0 taken 1640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1640 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1640 times.
✗ Branch 5 not taken.
1640 e = new eTrap((zfix)x,(zfix)y,id,clk);
17528 1640 break;
17529 }
17530
17531 2472 break;
17532 }
17533
17534 case eeDONGO:
17535 {
17536
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 203 times.
251 switch(guysbuf[id&0xFFF].attributes[9])
17537 {
17538 case 1:
17539
3/6
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
48 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
17540 48 break;
17541
17542 203 case 0:
17543 default:
17544
3/6
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 203 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 203 times.
✗ Branch 5 not taken.
203 e = new eDodongo((zfix)x,(zfix)y,id,clk);
17545 203 break;
17546 }
17547
17548 251 break;
17549 }
17550
17551 case eeDIG:
17552 {
17553
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 327 times.
✓ Branch 2 taken 76 times.
403 switch(guysbuf[id&0xFFF].attributes[9])
17554 {
17555 case 1:
17556
3/6
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 327 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 327 times.
✗ Branch 5 not taken.
327 e = new eLilDig((zfix)x,(zfix)y,id,clk);
17557 327 break;
17558
17559 76 case 0:
17560 default:
17561
3/6
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 76 times.
✗ Branch 5 not taken.
76 e = new eBigDig((zfix)x,(zfix)y,id,clk);
17562 76 break;
17563 }
17564
17565 403 break;
17566 }
17567
17568 case eePATRA:
17569 {
17570
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✓ Branch 2 taken 102 times.
292 switch(guysbuf[id&0xFFF].attributes[9])
17571 {
17572 case 1:
17573
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if (get_qr(qr_HARDCODED_BS_PATRA))
17574 {
17575
3/6
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 102 times.
✗ Branch 5 not taken.
102 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
17576 102 break;
17577 }
17578 [[fallthrough]];
17579 190 case 0:
17580 default:
17581
3/6
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 190 times.
✗ Branch 5 not taken.
190 e = new ePatra((zfix)x,(zfix)y,id,clk);
17582 190 break;
17583 }
17584
17585 292 break;
17586 }
17587
17588 case eeGUY:
17589 {
17590
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
5 switch(guysbuf[id&0xFFF].attributes[9])
17591 {
17592 case 1:
17593 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17594 break;
17595
17596 5 case 0:
17597 default:
17598
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
5 e = new eNPC((zfix)x,(zfix)y,id,clk);
17599 5 break;
17600 }
17601
17602 5 break;
17603 }
17604
17605 case eeNONE:
17606
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 if(guysbuf[id&0xFFF].attributes[9] ==1)
17607 {
17608
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
533 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17609 533 break;
17610 }
17611 [[fallthrough]];
17612 default:
17613
17614 return 0;
17615 }
17616
17617 102142 ret++; // Made one enemy.
17618
17619
4/4
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 101965 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 152 times.
102142 if(z && canfall(id))
17620 {
17621 152 e->z = (zfix)z;
17622 152 }
17623
17624
2/2
✓ Branch 0 taken 101965 times.
✓ Branch 1 taken 177 times.
102142 ((enemy*)e)->ceiling = (z && canfall(id));
17625
17626
1/2
✓ Branch 0 taken 102142 times.
✗ Branch 1 not taken.
102142 if(!guys.add(e))
17627 {
17628 return 0;
17629 }
17630
17631 // add segments of segmented enemies
17632 102142 int32_t c=0;
17633
17634
6/6
✓ Branch 0 taken 100495 times.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 149 times.
✓ Branch 4 taken 168 times.
✓ Branch 5 taken 292 times.
102142 switch(guysbuf[id&0xFFF].type)
17635 {
17636 case eeMOLD:
17637 {
17638 618 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17639 618 id &= 0xFFF;
17640
17641
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 3768 times.
✓ Branch 2 taken 3768 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3768 times.
✓ Branch 6 taken 3150 times.
✓ Branch 7 taken 618 times.
3768 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].attributes[0])); i++)
17642 {
17643 //christ this is messy -DD
17644 3150 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
17645
17646
4/8
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3150 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3150 times.
✗ Branch 7 not taken.
3150 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
17647 {
17648 al_trace("Moldorm segment %d could not be created!\n",i+1);
17649
17650 for(int32_t j=0; j<i+1; j++)
17651 guys.del(guys.Count()-1);
17652
17653 return 0;
17654 }
17655
17656
2/2
✓ Branch 0 taken 618 times.
✓ Branch 1 taken 2532 times.
3150 if(i>0)
17657 2532 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17658
17659 3150 ret++;
17660 3150 }
17661
17662 618 break;
17663 }
17664
17665 case eeLANM:
17666 {
17667 420 id &= 0xFFF;
17668 420 int32_t shft = guysbuf[id].attributes[1];
17669 420 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17670
17671
4/8
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 420 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 420 times.
✗ Branch 7 not taken.
420 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
17672 {
17673 al_trace("Lanmola segment 1 could not be created!\n");
17674 guys.del(guys.Count()-1);
17675 return 0;
17676 }
17677
17678 420 ret++;
17679
17680
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2267 times.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2267 times.
✓ Branch 6 taken 1847 times.
✓ Branch 7 taken 420 times.
2267 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])); i++)
17681 {
17682
4/8
✓ Branch 0 taken 1847 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1847 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1847 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1847 times.
✗ Branch 7 not taken.
1847 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
17683 {
17684 al_trace("Lanmola segment %d could not be created!\n",i+1);
17685
17686 for(int32_t j=0; j<i+1; j++)
17687 guys.del(guys.Count()-1);
17688
17689 return 0;
17690 }
17691
17692 1847 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17693 1847 ret++;
17694 1847 }
17695 }
17696 420 break;
17697
17698 case eeMANHAN:
17699 149 id &= 0xFFF;
17700
17701
2/2
✓ Branch 0 taken 688 times.
✓ Branch 1 taken 149 times.
837 for(int32_t i=0; i<((!(guysbuf[id].attributes[1]))?4:8); i++)
17702 {
17703
4/8
✓ Branch 0 taken 688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 688 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 688 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 688 times.
✗ Branch 7 not taken.
688 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
17704 {
17705 al_trace("Manhandla head %d could not be created!\n",i+1);
17706
17707 for(int32_t j=0; j<i+1; j++)
17708 {
17709 guys.del(guys.Count()-1);
17710 }
17711
17712 return 0;
17713 }
17714
17715 688 ret++;
17716 688 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].attributes[0];
17717 688 }
17718
17719 149 break;
17720
17721 case eeGLEEOK:
17722 {
17723 168 id &= 0xFFF;
17724 168 eGleeok* parent = (eGleeok*)e;
17725
17726
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 701 times.
✓ Branch 2 taken 669 times.
✓ Branch 3 taken 32 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 669 times.
✓ Branch 6 taken 533 times.
✓ Branch 7 taken 168 times.
701 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])); i++)
17727 {
17728
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
533 esGleeok* head = new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e);
17729
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 if(!guys.add(head))
17730 {
17731 al_trace("Gleeok head %d could not be created!\n",i+1);
17732
17733 for(int32_t j=0; j<i+1; j++)
17734 {
17735 guys.del(guys.Count()-1);
17736 }
17737
17738 return false;
17739 }
17740
17741 533 head->necktile=parent->necktile;
17742 533 head->dummy_int[1]=parent->necktile;
17743
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 112 times.
533 if(get_qr(qr_NEWENEMYTILES))
17744 {
17745 421 head->dummy_int[2]=parent->o_tile+parent->dmisc8; //connected head tile
17746 421 head->dummy_int[3]=parent->o_tile+parent->dmisc9; //flying head tile
17747 421 }
17748 else
17749 {
17750 112 head->dummy_int[2]=parent->necktile+1; //connected head tile
17751 112 head->dummy_int[3]=parent->necktile+2; //flying head tile
17752 }
17753 533 head->tile = head->dummy_int[2];
17754
17755 533 c-=guysbuf[id].attributes[3];
17756 533 ret++;
17757 533 }
17758 }
17759 168 break;
17760
17761
17762 case eePATRA:
17763 {
17764 292 id &= 0xFFF;
17765 292 int32_t outeyes = 0;
17766
17767
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2248 times.
✓ Branch 2 taken 1956 times.
✓ Branch 3 taken 292 times.
2248 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[0]); i++)
17768 {
17769
10/22
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 1344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 612 times.
✓ Branch 4 taken 612 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 612 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 612 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1344 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1344 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1344 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1344 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
1956 if(!((guysbuf[id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
17770 {
17771 al_trace("Patra outer eye %d could not be created!\n",i+1);
17772
17773 for(int32_t j=0; j<i+1; j++)
17774 guys.del(guys.Count()-1);
17775
17776 return 0;
17777 }
17778 else
17779 1956 outeyes++;
17780
17781 1956 ret++;
17782 1956 }
17783
17784
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
✓ Branch 2 taken 312 times.
✓ Branch 3 taken 292 times.
604 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[1]); i++)
17785 {
17786
4/8
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 312 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 312 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 312 times.
✗ Branch 7 not taken.
312 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
17787 {
17788 al_trace("Patra inner eye %d could not be created!\n",i+1);
17789
17790 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
17791 guys.del(guys.Count()-1);
17792
17793 return 0;
17794 }
17795
17796 312 ret++;
17797 312 }
17798
17799 292 break;
17800 }
17801 }
17802
17803
2/2
✓ Branch 0 taken 111048 times.
✓ Branch 1 taken 102142 times.
213190 for (int i = 0; i < ret; i++)
17804 {
17805 111048 enemy* e = (enemy*)guys.spr(guys.Count() - 1 - i);
17806 111048 e->screen_spawned = screen;
17807 111048 }
17808
17809 102142 return ret;
17810 102142 }
17811
17812 2059282 bool isjumper(int32_t id)
17813 {
17814
2/4
✓ Branch 0 taken 2059282 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2059282 times.
2059282 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17815 {
17816 return false;
17817 }
17818
3/3
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1953404 times.
✓ Branch 2 taken 105869 times.
2059282 switch(guysbuf[id&0xFFF].type)
17819 {
17820 case eeROCK:
17821 case eeTEK:
17822 9 return true;
17823
17824 case eeWALK:
17825
3/4
✓ Branch 0 taken 105869 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12265 times.
✓ Branch 3 taken 93604 times.
105869 if(guysbuf[id&0xFFF].attributes[8] == e9tVIRE || guysbuf[id & 0xFFF].attributes[8] == e9tPOLSVOICE) return true;
17826 93604 }
17827
17828 2047008 return false;
17829 2059282 }
17830
17831
17832 8068 bool isfixedtogrid(int32_t id)
17833 {
17834
2/4
✓ Branch 0 taken 8068 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8068 times.
8068 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17835 {
17836 return false;
17837 }
17838
1/2
✓ Branch 0 taken 8068 times.
✗ Branch 1 not taken.
8068 switch(guysbuf[id&0xFFF].type)
17839 {
17840 case eeWALK:
17841 case eeLEV:
17842 case eeZORA:
17843 case eeDONGO:
17844 case eeGANON:
17845 case eeROCK:
17846 case eeGLEEOK:
17847 case eeAQUA:
17848 case eeLANM:
17849 return true;
17850 }
17851
17852 8068 return false;
17853 8068 }
17854
17855 // Can't fall, can have Z value.
17856 76161798 bool isflier(int32_t id)
17857 {
17858
3/4
✓ Branch 0 taken 76161798 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110858 times.
✓ Branch 3 taken 76050940 times.
76161798 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17859 {
17860 110858 return false;
17861 }
17862
2/2
✓ Branch 0 taken 14067022 times.
✓ Branch 1 taken 61983918 times.
76050940 switch(guysbuf[id&0xFFF].type) //id&0x0FFF)
17863 {
17864 case eePEAHAT:
17865 case eeKEESE:
17866 case eePATRA:
17867 case eeFAIRY:
17868 case eeGHINI:
17869
17870 // Could theoretically have their Z set by a script
17871 case eeFIRE:
17872 14067022 return true;
17873 break;
17874 }
17875
17876 61983918 return false;
17877 76161798 }
17878
17879 // Can't have Z position
17880 4046103 bool never_in_air(int32_t id)
17881 {
17882
2/4
✓ Branch 0 taken 4046103 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4046103 times.
4046103 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17883 {
17884 return false;
17885 }
17886
2/2
✓ Branch 0 taken 4036553 times.
✓ Branch 1 taken 9550 times.
4046103 switch(guysbuf[id&0xFFF].type)
17887 {
17888 case eeMANHAN:
17889 case eeMOLD:
17890 case eeLANM:
17891 case eeGLEEOK:
17892 case eeZORA:
17893 case eeLEV:
17894 case eeAQUA:
17895 case eeROCK:
17896 case eeGANON:
17897 case eeTRAP:
17898 case eePROJECTILE:
17899 case eeSPINTILE:
17900 9550 return true;
17901 }
17902
17903 4036553 return false;
17904 4046103 }
17905
17906 2248208 bool canfall(int32_t id)
17907 {
17908
3/4
✓ Branch 0 taken 2248208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 2248162 times.
2248208 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17909 {
17910 46 return false;
17911 }
17912
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2248122 times.
✓ Branch 2 taken 40 times.
2248162 switch(guysbuf[id&0xFFF].type)
17913 {
17914 case eeGUY:
17915 {
17916
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(id < eOCTO1S)
17917 40 return false;
17918
17919 switch(guysbuf[id&0xFFF].attributes[9])
17920 {
17921 case 1:
17922 case 2:
17923 return true;
17924
17925 case 0:
17926 case 3:
17927 default:
17928 return false;
17929 }
17930
17931 case eeGHOMA:
17932 case eeDIG:
17933 return false;
17934 }
17935 }
17936
17937
17938
4/4
✓ Branch 0 taken 2239686 times.
✓ Branch 1 taken 8436 times.
✓ Branch 2 taken 180404 times.
✓ Branch 3 taken 2059282 times.
2248122 return !never_in_air(id) && !isflier(id) && !isjumper(id);
17939 2248208 }
17940
17941 73903985 bool enemy::enemycanfall(int32_t id, bool checkgrav)
17942 {
17943
3/4
✓ Branch 0 taken 73903985 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89598 times.
✓ Branch 3 taken 73814387 times.
73903985 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17944 {
17945 89598 return false;
17946 }
17947 //Z_scripterrlog("canfall family is %d:\n", family);
17948 //Z_scripterrlog("canfall gravity is %s:\n", moveflags & move_obeys_grav ? "true" : "false");
17949 //if ( family == eeFIRE && id >= eSTART )
17950 //{
17951 // Z_scripterrlog("eeFire\n");
17952 // return moveflags & move_obeys_grav; //'Other' enemy class, used by scripts. -Z
17953 //}
17954
17955 //In ZQ, eeFIRE is Other(floating) and eeOTHER is 'other'.
17956
17957
3/3
✓ Branch 0 taken 428935 times.
✓ Branch 1 taken 71307975 times.
✓ Branch 2 taken 2077477 times.
73814387 switch(guysbuf[id&0xFFF].type)
17958 {
17959 case eeGUY:
17960 {
17961
1/2
✓ Branch 0 taken 2077477 times.
✗ Branch 1 not taken.
2077477 if(id < eOCTO1S) //screen guys and fires that aren't real enemies, and never fall
17962 2077477 return false;
17963
17964 switch(guysbuf[id&0xFFF].attributes[9]) //I'm unsure what these specify off-hand. Needs better comments. -Z
17965 {
17966 case 1:
17967 case 2:
17968 return true;
17969
17970 case 0:
17971 case 3:
17972 default:
17973 return false;
17974 }
17975
17976 case eeGHOMA:
17977 case eeDIG:
17978 428935 return false;
17979 }
17980 }
17981
17982
2/2
✓ Branch 0 taken 39108925 times.
✓ Branch 1 taken 32199050 times.
71307975 if(!checkgrav) return true;
17983 39108925 return (moveflags & move_obeys_grav);
17984
17985 // if ( isflier(id) || isjumper(id) || never_in_air(id) )
17986 // {
17987 // if ( moveflags & move_obeys_grav ) return true;
17988 // else return false;
17989 // }
17990 // else
17991 // {
17992 // return (moveflags & move_obeys_grav);
17993 // }
17994 //return !never_in_air(id) && !isflier(id) && !isjumper(id);
17995 73903985 }
17996
17997 1271 void addfires()
17998 {
17999
2/2
✓ Branch 0 taken 814 times.
✓ Branch 1 taken 457 times.
1271 if(!get_qr(qr_NOGUYFIRES))
18000 {
18001 2285 auto [dx, dy] = translate_screen_coordinates_to_world(cur_screen);
18002 457 int32_t bs = get_qr(qr_BSZELDA);
18003 914 addguy(dx+(bs? 64: 72),dy+64,gFIRE,-17,false,nullptr);
18004 914 addguy(dx+(bs?176:168),dy+64,gFIRE,-18,false,nullptr);
18005 457 }
18006 1271 }
18007
18008 // This function runs one time for every screen on the first frame of a region being loaded.
18009 // It handles spawning screen guys (not the enemies), item, and room-specific sprites.
18010 37028 static void loadguys(mapscr* scr)
18011 {
18012 37028 int screen = scr->screen;
18013 37028 byte Guy=0;
18014 // When in caves/item rooms, use mSPECIALITEM and ipONETIME2
18015 // Else use mITEM and ipONETIME
18016 37028 int32_t mf = (screen>=128) ? mSPECIALITEM : mITEM;
18017 37028 int32_t onetime = (screen>=128) ? ipONETIME2 : ipONETIME;
18018
18019 37028 mapscr* guyscr = scr;
18020
4/4
✓ Branch 0 taken 906 times.
✓ Branch 1 taken 36122 times.
✓ Branch 2 taken 475 times.
✓ Branch 3 taken 431 times.
37028 if(screen>=128 && DMaps[cur_dmap].flags&dmfGUYCAVES)
18021 {
18022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 431 times.
431 if(DMaps[cur_dmap].flags&dmfCAVES)
18023 {
18024 431 Guy=special_warp_return_scr->guy;
18025 431 guyscr = special_warp_return_scr;
18026 431 }
18027 431 }
18028 else
18029 {
18030 36597 Guy=scr->guy;
18031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36597 times.
36597 if (game->get_regionmapping() == REGION_MAPPING_FULL)
18032 36597 mark_visited(screen);
18033 }
18034
18035 114000 auto [dx, dy] = translate_screen_coordinates_to_world(screen);
18036
18037 37028 bool oldguy = get_qr(qr_OLD_GUY_HANDLING);
18038 // The Guy appears if 'Hero is in cave' equals 'Guy is in cave'.
18039
4/4
✓ Branch 0 taken 3865 times.
✓ Branch 1 taken 33163 times.
✓ Branch 2 taken 2550 times.
✓ Branch 3 taken 1315 times.
37028 if(Guy && ((screen>=128) == !!(DMaps[cur_dmap].flags&dmfGUYCAVES)))
18040 {
18041
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1304 times.
1315 if(scr->room==rZELDA)
18042 {
18043 22 addguy(dx+120,dy+72,Guy,-15,true,guyscr);
18044 11 guys.spr(0)->hxofs=1000;
18045 33 addenemy(screen,dx+128,dy+96,eFIRE,-15);
18046 33 addenemy(screen,dx+112,dy+96,eFIRE,-15);
18047 33 addenemy(screen,dx+96,dy+120,eFIRE,-15);
18048 33 addenemy(screen,dx+144,dy+120,eFIRE,-15);
18049 11 return;
18050 }
18051
18052
2/2
✓ Branch 0 taken 1300 times.
✓ Branch 1 taken 4 times.
2604 bool ffire = oldguy
18053
2/2
✓ Branch 0 taken 1271 times.
✓ Branch 1 taken 29 times.
1300 ? (Guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES))
18054 4 : (guyscr->roomflags&RFL_GUYFIRES);
18055
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 1271 times.
1304 if(ffire)
18056 1271 addfires();
18057
18058
2/2
✓ Branch 0 taken 879 times.
✓ Branch 1 taken 425 times.
1304 if(screen>=128)
18059
3/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 412 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
438 if(getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))
18060 13 Guy=0;
18061
18062
4/6
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 1091 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 45 times.
1304 switch(scr->room)
18063 {
18064 case rSP_ITEM:
18065 case rGRUMBLE:
18066 case rBOMBS:
18067 case rARROWS:
18068 case rSWINDLE:
18069 case rMUPGRADE:
18070 case rLEARNSLASH:
18071 case rTAKEONE:
18072
8/8
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 49 times.
✓ Branch 4 taken 63 times.
✓ Branch 5 taken 49 times.
✓ Branch 6 taken 21 times.
✓ Branch 7 taken 42 times.
167 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18073 55 Guy=0;
18074
18075 167 break;
18076
18077 case rREPAIR:
18078 if (get_qr(qr_OLD_DOORREPAIR)) break;
18079 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18080 Guy=0;
18081
18082 break;
18083 case rRP_HC:
18084 if (get_qr(qr_OLD_POTION_OR_HC)) break;
18085 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18086 Guy=0;
18087
18088 break;
18089 case rMONEY:
18090
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (get_qr(qr_OLD_SECRETMONEY)) break;
18091 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18092 Guy=0;
18093
18094 break;
18095
18096 case rTRIFORCE:
18097 {
18098 45 int32_t tc = TriforceCount();
18099
18100
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 34 times.
45 if(get_qr(qr_4TRI))
18101 {
18102
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
11 if((get_qr(qr_3TRI) && tc>=3) || tc>=4)
18103 10 Guy=0;
18104 9 }
18105 else
18106 {
18107
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 1 times.
34 if((get_qr(qr_3TRI) && tc>=6) || tc>=8)
18108 33 Guy=0;
18109 }
18110 }
18111 43 break;
18112 }
18113
18114
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 1195 times.
1302 if(Guy)
18115 {
18116
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 1162 times.
1195 if(ffire)
18117 1162 blockpath=true;
18118
18119
2/2
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 783 times.
1195 if(screen<128)
18120 783 sfx(WAV_SCALE);
18121
18122
6/6
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 728 times.
✓ Branch 2 taken 467 times.
✓ Branch 3 taken 728 times.
✓ Branch 4 taken 110 times.
✓ Branch 5 taken 357 times.
2390 addguy(dx+120,dy+64,Guy, (dlevel||BSZ)?-15:startguy[zc_oldrand()&7], true, guyscr);
18123 1195 Hero.Freeze();
18124 1195 }
18125 1302 }
18126
5/6
✓ Branch 0 taken 33904 times.
✓ Branch 1 taken 1809 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 33833 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1809 times.
35713 else if(oldguy ? Guy==gFAIRY : (Guy && (guyscr->roomflags&RFL_ALWAYS_GUY))) // The only Guy that somewhat ignores the "Guys In Caves Only" DMap flag
18127 {
18128 71 sfx(WAV_SCALE);
18129 142 addguy(dx+120,dy+62,gFAIRY,-14,false,guyscr);
18130 71 }
18131
18132 111045 loaditem(scr, dx, dy);
18133
18134 // Collecting a rupee in a '10 Rupees' screen sets the mITEM screen state if
18135 // it doesn't appear in a Cave/Item Cellar, and the mSPECIALITEM screen state if it does.
18136
4/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 36996 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 15 times.
37015 if (scr->room==r10RUPIES && !getmapflag(screen, mf))
18137 {
18138
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 15 times.
165 for(int32_t i=0; i<10; i++)
18139 300 additem(dx+ten_rupies_x[i],dy+ten_rupies_y[i],0,ipBIGRANGE+onetime,-14);
18140 15 }
18141 37026 }
18142
18143 35784 void loadguys()
18144 {
18145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35784 times.
35784 if (loaded_guys)
18146 return;
18147
18148 35784 loaded_guys = true;
18149 35784 repaircharge = 0;
18150 35784 adjustmagic = false;
18151 35784 learnslash = false;
18152
2/2
✓ Branch 0 taken 107352 times.
✓ Branch 1 taken 35784 times.
143136 for (int32_t i=0; i<3; i++)
18153 {
18154 107352 prices[i] = 0;
18155 107352 }
18156
18157 72812 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
18158 37028 get_screen_state(scr->screen).item_state = ScreenItemState::None;
18159 37028 loadguys(scr);
18160 37028 });
18161 35784 }
18162
18163 37034 void loaditem(mapscr* scr, int offx, int offy)
18164 {
18165 37034 int screen = scr->screen;
18166 37034 byte Item = 0;
18167
18168
2/2
✓ Branch 0 taken 36128 times.
✓ Branch 1 taken 906 times.
37034 if(screen<128)
18169 {
18170 36128 Item=scr->item;
18171
18172
4/4
✓ Branch 0 taken 1593 times.
✓ Branch 1 taken 34535 times.
✓ Branch 2 taken 32910 times.
✓ Branch 3 taken 3218 times.
36128 if((!getmapflag(screen, mITEM) || (scr->flags9&fITEMRETURN)) && (scr->hasitem != 0))
18173 {
18174
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 3159 times.
3218 if(scr->flags8&fSECRETITEM)
18175 59 screen_item_set_state(screen, ScreenItemState::WhenTriggerSecrets);
18176
2/2
✓ Branch 0 taken 1164 times.
✓ Branch 1 taken 1995 times.
3159 else if(scr->flags&fITEM)
18177 1164 screen_item_set_state(screen, ScreenItemState::WhenKillEnemies);
18178
2/2
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 1886 times.
1995 else if(scr->flags11&efCARRYITEM)
18179 109 screen_item_set_state(screen, ScreenItemState::MustGiveToEnemy); // Will be set to CarriedByEnemy in roaming_item
18180 else
18181 {
18182 1886 int x = scr->itemx;
18183
3/4
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 1871 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
1886 int y = scr->flags7&fITEMFALLS && isSideViewGravity() ?
18184 -170 :
18185 1886 scr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1);
18186
3/6
✓ Branch 0 taken 1886 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1886 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1886 times.
✗ Branch 5 not taken.
3772 add_item_for_screen(screen, new item(offx + x, offy + y,
18187
6/10
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 1871 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1871 times.
✗ Branch 9 not taken.
1886 (scr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
18188
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 1781 times.
1886 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].type==itype_triforcepiece ||
18189 1886 (scr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
18190 }
18191 3218 }
18192 36128 }
18193
2/2
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 475 times.
906 else if(!(DMaps[cur_dmap].flags&dmfCAVES))
18194 {
18195
4/6
✓ Branch 0 taken 475 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 469 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
491 if((!getmapflag(screen, (screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (special_warp_return_scr->flags9&fBELOWRETURN)) && special_warp_return_scr->room==rSP_ITEM
18196
4/4
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 312 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 147 times.
475 && (screen==128 || !get_qr(qr_ITEMSINPASSAGEWAYS)))
18197 {
18198 163 Item = special_warp_return_scr->catchall;
18199
18200
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 162 times.
163 if(Item)
18201 {
18202 162 int x = scr->itemx;
18203
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
162 int y = scr->flags7&fITEMFALLS && isSideViewGravity() ?
18204 -170 :
18205 162 scr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1);
18206
3/6
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 162 times.
✗ Branch 5 not taken.
324 add_item_for_screen(screen, new item(offx + x, offy + y,
18207
2/10
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 162 times.
✗ Branch 9 not taken.
162 (scr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
18208 162 Item,ipONETIME2|ipBIGRANGE|ipHOLDUP | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
18209 162 }
18210 163 }
18211 475 }
18212 37034 }
18213
18214 957 void never_return(int32_t screen, int32_t index)
18215 {
18216
2/2
✓ Branch 0 taken 766 times.
✓ Branch 1 taken 191 times.
957 if(!get_qr(qr_KILLALL))
18217 191 goto doit;
18218
18219
2/2
✓ Branch 0 taken 2292 times.
✓ Branch 1 taken 329 times.
2621 for(int32_t i=0; i<guys.Count(); i++)
18220
4/4
✓ Branch 0 taken 980 times.
✓ Branch 1 taken 1312 times.
✓ Branch 2 taken 543 times.
✓ Branch 3 taken 437 times.
2292 if(((((enemy*)guys.spr(i))->d->flags)&guy_never_return) && i!=index)
18221 {
18222 437 goto dontdoit;
18223 329 }
18224
18225 doit:
18226 520 setmapflag(get_scr(screen), mNEVERRET);
18227 dontdoit:
18228 957 return;
18229 }
18230
18231 63753 bool slowguy(int32_t id)
18232 {
18233
2/4
✓ Branch 0 taken 63753 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 63753 times.
63753 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
18234 {
18235 return false;
18236 }
18237
18238 63753 id = id&0xFFF;
18239
18240
2/2
✓ Branch 0 taken 54110 times.
✓ Branch 1 taken 9643 times.
63753 switch(id)
18241 {
18242 case eOCTO1S:
18243 case eOCTO2S:
18244 case eOCTO1F:
18245 case eOCTO2F:
18246 case eLEV1:
18247 case eLEV2:
18248 case eROCK:
18249 case eBOULDER:
18250 9643 return true;
18251 }
18252
18253 54110 return false;
18254 63753 }
18255
18256 83364 static bool ok2add(mapscr* scr, int32_t id)
18257 {
18258
2/4
✓ Branch 0 taken 83364 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 83364 times.
83364 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
18259 {
18260 return false;
18261 }
18262
18263 83364 id = id&0xFFF;
18264
18265
4/4
✓ Branch 0 taken 829 times.
✓ Branch 1 taken 82535 times.
✓ Branch 2 taken 464 times.
✓ Branch 3 taken 365 times.
83364 if(getmapflag(scr, mNEVERRET) && (guysbuf[id].flags & guy_never_return))
18266 464 return false;
18267
18268
4/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 82259 times.
✓ Branch 2 taken 376 times.
✓ Branch 3 taken 201 times.
82900 switch(guysbuf[id].type)
18269 {
18270 // I added a special case for shooters because having traps on the same screen
18271 // was preventing them from spawning due to TMPNORET. This means they will
18272 // never stay dead, though, so it may not be the best solution. - Saf
18273 case eePROJECTILE:
18274 376 return true;
18275
18276
18277 case eeDIG:
18278 {
18279
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 75 times.
201 switch(guysbuf[id].attributes[9])
18280 {
18281 case 1:
18282
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 47 times.
126 if(!get_qr(qr_NOTMPNORET))
18283 79 return !getmapflag(scr, mTMPNORET);
18284
18285 47 return true;
18286
18287 75 case 0:
18288 default:
18289 75 return true;
18290 }
18291 }
18292 case eeGANON:
18293 case eeTRAP:
18294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
128 if ((guysbuf[id].type == eeGANON && !get_qr(qr_CAN_PLACE_GANON))
18295
4/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 64 times.
64 || (guysbuf[id].type == eeTRAP && !get_qr(qr_CAN_PLACE_TRAPS))) return false;
18296 [[fallthrough]];
18297 default:
18298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82259 times.
82259 if (guysbuf[id].flags&guy_ignoretmpnr) return true;
18299 82259 break;
18300 }
18301
18302
2/2
✓ Branch 0 taken 20978 times.
✓ Branch 1 taken 61281 times.
82259 if(!get_qr(qr_NOTMPNORET))
18303 61281 return !getmapflag(scr, mTMPNORET);
18304
18305 20978 return true;
18306 83364 }
18307
18308 1634105 static void activate_fireball_statue(const rpos_handle_t& rpos_handle)
18309 {
18310
3/4
✓ Branch 0 taken 288841 times.
✓ Branch 1 taken 1345264 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 288841 times.
1634105 if (!(rpos_handle.scr->flags11&efFIREBALLS) || statueID<0)
18311 {
18312 1345264 return;
18313 }
18314
18315 288841 int32_t ctype = rpos_handle.ctype();
18316
6/6
✓ Branch 0 taken 287333 times.
✓ Branch 1 taken 1508 times.
✓ Branch 2 taken 286018 times.
✓ Branch 3 taken 1315 times.
✓ Branch 4 taken 1213 times.
✓ Branch 5 taken 284805 times.
288841 if (ctype != cL_STATUE && ctype != cR_STATUE && ctype != cC_STATUE) return;
18317
18318 12108 auto [x, y] = rpos_handle.xy();
18319
18320 4036 int32_t cx=-1000, cy=-1000;
18321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4036 times.
4036 if(!isfixedtogrid(statueID))
18322 {
18323
2/2
✓ Branch 0 taken 1508 times.
✓ Branch 1 taken 2528 times.
4036 if(ctype==cL_STATUE)
18324 {
18325 1508 cx=x+4;
18326 1508 cy=y+7;
18327 1508 }
18328
2/2
✓ Branch 0 taken 1315 times.
✓ Branch 1 taken 1213 times.
2528 else if(ctype==cR_STATUE)
18329 {
18330 1315 cx=x-8;
18331 1315 cy=y-1;
18332 1315 }
18333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1213 times.
1213 else if(ctype==cC_STATUE)
18334 {
18335 1213 cx=x;
18336 1213 cy=y;
18337 1213 }
18338 4036 }
18339 else if(ctype==cL_STATUE || ctype==cR_STATUE || ctype==cC_STATUE)
18340 {
18341 cx=x;
18342 cy=y;
18343 }
18344
18345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4036 times.
4036 if(cx!=-1000) // No point creating it if this is false
18346 {
18347
2/2
✓ Branch 0 taken 9754 times.
✓ Branch 1 taken 4032 times.
13786 for(int32_t j=0; j<guys.Count(); j++)
18348 {
18349
4/4
✓ Branch 0 taken 1698 times.
✓ Branch 1 taken 8056 times.
✓ Branch 2 taken 1694 times.
✓ Branch 3 taken 4 times.
9754 if((int32_t(guys.spr(j)->x)==cx)&&(int32_t(guys.spr(j)->y)==cy))
18350 {
18351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if((guys.spr(j)->id&0xFFF) == statueID) // There's already a matching enemy here!
18352 4 return; // No point deleting it. A script might be toying with it in some way.
18353 else
18354 guys.del(j);
18355 }
18356 9750 }
18357
18358 4032 addenemy(rpos_handle.screen, cx, cy, statueID, !isfixedtogrid(statueID) ? 24 : 0);
18359 4032 }
18360 1634105 }
18361
18362 34365 static void activate_fireball_statues(mapscr* scr)
18363 {
18364
2/2
✓ Branch 0 taken 32946 times.
✓ Branch 1 taken 1419 times.
34365 if (!(scr->flags11&efFIREBALLS))
18365 {
18366 32946 return;
18367 }
18368
18369 251163 for_every_rpos_in_screen_layer0(scr, [&](const rpos_handle_t& rpos_handle) {
18370 249744 activate_fireball_statue(rpos_handle);
18371 249744 });
18372 34365 }
18373
18374 35048 void load_default_enemies(mapscr* scr)
18375 {
18376 35048 int screen = scr->screen;
18377 40513 auto [dx, dy] = translate_screen_coordinates_to_world(screen);
18378
18379 35048 wallm_load_clk=frame-80;
18380
18381
2/2
✓ Branch 0 taken 33152 times.
✓ Branch 1 taken 1896 times.
35048 if(scr->flags11&efZORA)
18382 {
18383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1896 times.
1896 if(zoraID>=0)
18384 5688 addenemy(screen, dx - 16, dy - 16, zoraID, 0);
18385 1896 }
18386
18387
2/2
✓ Branch 0 taken 34870 times.
✓ Branch 1 taken 178 times.
35048 if(scr->flags11&efTRAP4)
18388 {
18389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 178 times.
178 if(cornerTrapID>=0)
18390 {
18391 534 addenemy(screen, dx + 32, dy + 32, cornerTrapID, -14);
18392 534 addenemy(screen, dx + 208, dy + 32, cornerTrapID, -14);
18393 534 addenemy(screen, dx + 32, dy + 128, cornerTrapID, -14);
18394 534 addenemy(screen, dx + 208, dy + 128, cornerTrapID, -14);
18395 178 }
18396 178 }
18397
18398 6203496 for_every_rpos_in_screen_layer0(scr, [&](const rpos_handle_t& rpos_handle) {
18399 6168448 int32_t ctype = rpos_handle.ctype();
18400 6168448 int32_t cflag = rpos_handle.sflag();
18401 6168448 int32_t cflag_i = rpos_handle.cflag();
18402
18403
4/6
✓ Branch 0 taken 6168448 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6168102 times.
✓ Branch 3 taken 346 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6168102 times.
6168448 if(ctype==cTRAP_H || cflag==mfTRAP_H || cflag_i==mfTRAP_H)
18404 {
18405 346 auto [x, y] = rpos_handle.xy();
18406
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 336 times.
346 if(trapLOSHorizontalID>=0)
18407 1008 addenemy(screen, x, y, trapLOSHorizontalID, -14);
18408 346 }
18409
4/6
✓ Branch 0 taken 6168102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6167896 times.
✓ Branch 3 taken 206 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6167896 times.
6168102 else if(ctype==cTRAP_V || cflag==mfTRAP_V || cflag_i==mfTRAP_V)
18410 {
18411 206 auto [x, y] = rpos_handle.xy();
18412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 206 times.
206 if(trapLOSVerticalID>=0)
18413 618 addenemy(screen, x, y, trapLOSVerticalID, -14);
18414 206 }
18415
4/6
✓ Branch 0 taken 6167896 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6167618 times.
✓ Branch 3 taken 278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6167618 times.
6167896 else if(ctype==cTRAP_4 || cflag==mfTRAP_4 || cflag_i==mfTRAP_4)
18416 {
18417 278 auto [x, y] = rpos_handle.xy();
18418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
278 if(trapLOS4WayID>=0)
18419 {
18420
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 278 times.
834 if(addenemy(screen, x, y, trapLOS4WayID, -14))
18421 278 guys.spr(guys.Count()-1)->dummy_int[1]=2;
18422 278 }
18423 278 }
18424
4/6
✓ Branch 0 taken 6167618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6167219 times.
✓ Branch 3 taken 399 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6167219 times.
6167618 else if(ctype==cTRAP_LR || cflag==mfTRAP_LR || cflag_i==mfTRAP_LR)
18425 {
18426 399 auto [x, y] = rpos_handle.xy();
18427
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 399 times.
399 if(trapConstantHorizontalID>=0)
18428 1197 addenemy(screen, x, y, trapConstantHorizontalID, -14);
18429 399 }
18430
4/6
✓ Branch 0 taken 6167219 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6166786 times.
✓ Branch 3 taken 433 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6166786 times.
6167219 else if(ctype==cTRAP_UD || cflag==mfTRAP_UD || cflag_i==mfTRAP_UD)
18431 {
18432 433 auto [x, y] = rpos_handle.xy();
18433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 433 times.
433 if(trapConstantVerticalID>=0)
18434 1299 addenemy(screen, x, y, trapConstantVerticalID, -14);
18435 433 }
18436
18437
1/2
✓ Branch 0 taken 6168448 times.
✗ Branch 1 not taken.
6168448 if(ctype==cSPINTILE1)
18438 {
18439 awaken_spinning_tile(rpos_handle);
18440 }
18441 6168448 });
18442
18443
2/2
✓ Branch 0 taken 34992 times.
✓ Branch 1 taken 56 times.
35048 if(scr->flags11&efTRAP2)
18444 {
18445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(centerTrapID>=-1)
18446 {
18447
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(addenemy(screen, 64, 80, centerTrapID, -14))
18448 56 guys.spr(guys.Count()-1)->dummy_int[1]=1;
18449
18450
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(addenemy(screen, 176, 80, centerTrapID, -14))
18451 56 guys.spr(guys.Count()-1)->dummy_int[1]=1;
18452 56 }
18453 56 }
18454
18455
2/2
✓ Branch 0 taken 34965 times.
✓ Branch 1 taken 83 times.
35048 if(scr->flags11&efROCKS)
18456 {
18457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if(rockID>=0)
18458 {
18459 166 addenemy(screen, dx + (zc_oldrand()&0xF0), 0, rockID, 0);
18460 166 addenemy(screen, dx + (zc_oldrand()&0xF0), 0, rockID, 0);
18461 166 addenemy(screen, dx + (zc_oldrand()&0xF0), 0, rockID, 0);
18462 83 }
18463 83 }
18464 35048 }
18465
18466 #define SLOPE_STAGE_COMBOS 0
18467 #define SLOPE_STAGE_FFCS 1
18468 #define SLOPE_STAGE_COMBOS_BORDERING_SCREENS 2
18469
18470 21192911 static slope_id_t create_slope_id(int stage, int arg1, int arg2)
18471 {
18472
2/2
✓ Branch 0 taken 4641750 times.
✓ Branch 1 taken 16551161 times.
21192911 if (stage == SLOPE_STAGE_COMBOS)
18473 16551161 return (region_num_rpos*arg1)+arg2;
18474
2/2
✓ Branch 0 taken 4500554 times.
✓ Branch 1 taken 141196 times.
4641750 if (stage == SLOPE_STAGE_FFCS)
18475 4500554 return (region_num_rpos*7)+arg1;
18476
1/2
✓ Branch 0 taken 141196 times.
✗ Branch 1 not taken.
141196 if (stage == SLOPE_STAGE_COMBOS_BORDERING_SCREENS)
18477 141196 return (region_num_rpos*7 + MAX_FFCID+1)+arg1*7*(16 * 2 + 11 * 2) + arg2;
18478 // TODO: what about FFCs from bordering screens?
18479
18480 assert(false);
18481 return 0;
18482 21192911 }
18483
18484 16551161 void update_slope_combopos(const rpos_handle_t& rpos_handle)
18485 {
18486 16551161 mapscr* s = rpos_handle.scr;
18487 16551161 auto& cmb = rpos_handle.combo();
18488
18489 16551161 auto id = create_slope_id(SLOPE_STAGE_COMBOS, rpos_handle.layer, (int)rpos_handle.rpos);
18490 16551161 auto it = slopes.find(id);
18491
18492 16551161 bool wasSlope = it!=slopes.end();
18493 16551161 bool isSlope = cmb.type == cSLOPE;
18494
18495
3/4
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 16551025 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
16551161 if(isSlope && !wasSlope)
18496 {
18497 272 auto [x, y] = rpos_handle.xy();
18498 272 slopes.try_emplace(id, &(s->data[rpos_handle.pos]), nullptr, -1, x, y);
18499 136 }
18500
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16551025 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16551025 else if(wasSlope && !isSlope)
18501 {
18502 slopes.erase(it);
18503 }
18504 16551161 }
18505
18506 141196 static void update_slope_combopos_bordering_screen(int dir, int slope_count, int cid, bool is_slope, int offx, int offy)
18507 {
18508 141196 auto id = create_slope_id(SLOPE_STAGE_COMBOS_BORDERING_SCREENS, dir, slope_count);
18509 141196 auto it = slopes.find(id);
18510
18511 141196 bool wasSlope = it!=slopes.end();
18512 141196 bool isSlope = is_slope;
18513
18514
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 141196 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
141196 if(isSlope && !wasSlope)
18515 {
18516 static std::vector<word> TMP;
18517 int num_border_combos = cur_region.screen_width*16 * 2 + cur_region.screen_height*11 * 2;
18518 TMP.resize(num_border_combos * 7 * 4);
18519
18520 int tmp_index = id-create_slope_id(SLOPE_STAGE_COMBOS_BORDERING_SCREENS,0,0);
18521 TMP[tmp_index] = cid;
18522 slopes.try_emplace(id, &TMP[tmp_index], nullptr, -1, offx, offy);
18523 }
18524
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 141196 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
141196 else if(wasSlope && !isSlope)
18525 {
18526 slopes.erase(it);
18527 }
18528 141196 }
18529
18530 // Load a single column or row from a nearby screen, and load its slopes.
18531 3884 static void handle_slope_combopos_bordering_screen(int initial_screen, int dir)
18532 {
18533 55866 auto [map, screen] = nextscr2(cur_map, initial_screen, dir);
18534
2/2
✓ Branch 0 taken 3713 times.
✓ Branch 1 taken 171 times.
3884 if (map == -1)
18535 171 return;
18536
18537 3713 int offx = 0;
18538 3713 int offy = 0;
18539
2/2
✓ Branch 0 taken 2800 times.
✓ Branch 1 taken 913 times.
3713 if (dir == up)
18540 913 offy = -16;
18541
2/2
✓ Branch 0 taken 862 times.
✓ Branch 1 taken 1938 times.
2800 else if (dir == down)
18542 862 offy = world_h;
18543
2/2
✓ Branch 0 taken 968 times.
✓ Branch 1 taken 970 times.
1938 else if (dir == left)
18544 968 offx = -16;
18545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 970 times.
970 else if (dir == right)
18546 970 offx = world_w;
18547
18548
2/2
✓ Branch 0 taken 3713 times.
✓ Branch 1 taken 25991 times.
29704 for (int layer = 0; layer < 7; layer++)
18549 {
18550 51982 auto scr = load_temp_mapscr_and_apply_secrets(map, screen, layer - 1, true, false);
18551
2/2
✓ Branch 0 taken 10526 times.
✓ Branch 1 taken 15465 times.
25991 if (!scr) continue;
18552
18553 10526 int slope_count = layer * (16*2);
18554
18555
4/4
✓ Branch 0 taken 7826 times.
✓ Branch 1 taken 2700 times.
✓ Branch 2 taken 2744 times.
✓ Branch 3 taken 5082 times.
10526 if (dir == left || dir == right)
18556 {
18557 5444 int x = dir == left ? 15 : 0;
18558
2/2
✓ Branch 0 taken 59884 times.
✓ Branch 1 taken 5444 times.
65328 for (int y = 0; y < 11; y++)
18559 {
18560 59884 int pos = y * 16 + x;
18561 59884 int cid = scr->data[pos];
18562 59884 bool is_slope = combobuf[cid].type == cSLOPE;
18563
1/2
✓ Branch 0 taken 59884 times.
✗ Branch 1 not taken.
59884 update_slope_combopos_bordering_screen(dir, slope_count++, cid, is_slope, offx, offy + y*16);
18564 59884 }
18565 5444 }
18566
3/4
✓ Branch 0 taken 2437 times.
✓ Branch 1 taken 2645 times.
✓ Branch 2 taken 2437 times.
✗ Branch 3 not taken.
5082 else if (dir == up || dir == down)
18567 {
18568 5082 int y = dir == up ? 10 : 0;
18569
2/2
✓ Branch 0 taken 81312 times.
✓ Branch 1 taken 5082 times.
86394 for (int x = 0; x < 16; x++)
18570 {
18571 81312 int pos = y * 16 + x;
18572 81312 int cid = scr->data[pos];
18573 81312 bool is_slope = combobuf[cid].type == cSLOPE;
18574
1/2
✓ Branch 0 taken 81312 times.
✗ Branch 1 not taken.
81312 update_slope_combopos_bordering_screen(dir, slope_count++, cid, is_slope, offx + x*16, offy);
18575 81312 }
18576 5082 }
18577
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 15465 times.
✓ Branch 2 taken 10526 times.
25991 }
18578 3884 }
18579
18580 35854 void update_slope_comboposes()
18581 {
18582 15202654 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
18583 15166800 update_slope_combopos(rpos_handle);
18584 15166800 });
18585
18586
2/2
✓ Branch 0 taken 34883 times.
✓ Branch 1 taken 971 times.
35854 if (Hero.sideview_mode())
18587 {
18588 1942 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
18589
2/2
✓ Branch 0 taken 3884 times.
✓ Branch 1 taken 971 times.
4855 for (int dir = up; dir <= right; dir++)
18590 3884 handle_slope_combopos_bordering_screen(scr->screen, dir);
18591 971 });
18592 971 }
18593
18594 35854 update_slopes();
18595 35854 }
18596
18597 // Everything that must be done before we change a screen's combo to another combo, or a combo's type to another type.
18598 1384361 void screen_combo_modify_preroutine(const rpos_handle_t& rpos_handle)
18599 {
18600 1384361 delete_fireball_shooter(rpos_handle);
18601 1384361 }
18602
18603 //Placeholder in case we need it.
18604 void screen_ffc_modify_preroutine(const ffc_handle_t& ffc_handle)
18605 {
18606 return;
18607 }
18608
18609 // Everything that must be done after we change a screen's combo to another combo. -L
18610 1384361 void screen_combo_modify_postroutine(const rpos_handle_t& rpos_handle)
18611 {
18612 1384361 rpos_handle.scr->valid |= mVALID;
18613 1384361 activate_fireball_statue(rpos_handle);
18614
18615
2/2
✓ Branch 0 taken 1384267 times.
✓ Branch 1 taken 94 times.
1384361 if(rpos_handle.ctype()==cSPINTILE1)
18616 {
18617 94 awaken_spinning_tile(rpos_handle);
18618 94 }
18619
18620 1384361 update_slope_combopos(rpos_handle);
18621 1384361 }
18622
18623 4500554 void screen_ffc_modify_postroutine(const ffc_handle_t& ffc_handle)
18624 {
18625 4500554 ffcdata* ff = ffc_handle.ffc;
18626 4500554 auto& cmb = ffc_handle.combo();
18627
18628 4500554 auto id = create_slope_id(SLOPE_STAGE_FFCS, ffc_handle.id, -1);
18629 4500554 auto it = slopes.find(id);
18630
18631 4500554 bool wasSlope = it!=slopes.end();
18632
1/2
✓ Branch 0 taken 4500554 times.
✗ Branch 1 not taken.
4500554 bool isSlope = cmb.type == cSLOPE && !(ff->flags&ffc_changer);
18633
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4500554 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4500554 if(isSlope && !wasSlope)
18634 {
18635 slopes.try_emplace(id, nullptr, ff, ffc_handle.id);
18636 }
18637
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4500554 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4500554 else if(wasSlope && !isSlope)
18638 {
18639 slopes.erase(it);
18640 }
18641
18642 4500554 ffc_handle.scr->ffcCountMarkDirty();
18643 4500554 }
18644
18645 4414 void screen_combo_modify_pre(int32_t cid)
18646 {
18647 2813022 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
18648
2/2
✓ Branch 0 taken 2803413 times.
✓ Branch 1 taken 5195 times.
2808608 if (rpos_handle.data() == cid)
18649 {
18650 5195 screen_combo_modify_preroutine(rpos_handle);
18651 5195 }
18652 2808608 });
18653 4414 }
18654 4414 void screen_combo_modify_post(int32_t cid)
18655 {
18656 4414 combo_caches::refresh(cid);
18657
18658 2813022 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
18659
2/2
✓ Branch 0 taken 2803413 times.
✓ Branch 1 taken 5195 times.
2808608 if (rpos_handle.data() == cid)
18660 {
18661 5195 screen_combo_modify_postroutine(rpos_handle);
18662 5195 }
18663 2808608 });
18664
18665 144186 for_every_ffc([&](const ffc_handle_t& ffc_handle) {
18666
2/2
✓ Branch 0 taken 139714 times.
✓ Branch 1 taken 58 times.
139772 if (ffc_handle.data() == cid)
18667 {
18668 58 screen_ffc_modify_postroutine(ffc_handle);
18669 58 }
18670 139772 });
18671 4414 }
18672
18673 94 void awaken_spinning_tile(const rpos_handle_t& rpos_handle)
18674 {
18675 94 int cid = rpos_handle.data();
18676 94 int cset = rpos_handle.cset();
18677 282 auto [x, y] = rpos_handle.xy();
18678
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 94 times.
282 addenemy(rpos_handle.screen, x, y, (cset<<12)+eSPINTILE1, combobuf[cid].o_tile + zc_max(1,combobuf[cid].frames));
18679 94 }
18680
18681 // It stands for next_side_pos
18682 // moves sle_x and sle_y to the next position
18683 11464 void nsp(bool random)
18684 {
18685
2/2
✓ Branch 0 taken 3261 times.
✓ Branch 1 taken 8203 times.
11464 if(random)
18686 {
18687
2/2
✓ Branch 0 taken 1634 times.
✓ Branch 1 taken 1627 times.
3261 if(zc_oldrand()%2)
18688 {
18689 1634 sle_x = (zc_oldrand()%2) ? 0 : 240;
18690 1634 sle_y = (zc_oldrand()%10)*16;
18691 1634 }
18692 else
18693 {
18694 1627 sle_y = (zc_oldrand()%2) ? 0 : 160;
18695 1627 sle_x = (zc_oldrand()%15)*16;
18696 }
18697
18698 3261 return;
18699 }
18700
18701
2/2
✓ Branch 0 taken 6168 times.
✓ Branch 1 taken 2035 times.
8203 if(sle_x==0)
18702 {
18703
2/2
✓ Branch 0 taken 1855 times.
✓ Branch 1 taken 180 times.
2035 if(sle_y<160)
18704 1855 sle_y+=16;
18705 else
18706 180 sle_x+=16;
18707 2035 }
18708
2/2
✓ Branch 0 taken 2596 times.
✓ Branch 1 taken 3572 times.
6168 else if(sle_y==160)
18709 {
18710
2/2
✓ Branch 0 taken 2430 times.
✓ Branch 1 taken 166 times.
2596 if(sle_x<240)
18711 2430 sle_x+=16;
18712 else
18713 166 sle_y-=16;
18714 2596 }
18715
2/2
✓ Branch 0 taken 1552 times.
✓ Branch 1 taken 2020 times.
3572 else if(sle_x==240)
18716 {
18717
2/2
✓ Branch 0 taken 1404 times.
✓ Branch 1 taken 148 times.
1552 if(sle_y>0)
18718 1404 sle_y-=16;
18719 else
18720 148 sle_x-=16;
18721 1552 }
18722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2020 times.
2020 else if(sle_y==0)
18723 {
18724
1/2
✓ Branch 0 taken 2020 times.
✗ Branch 1 not taken.
2020 if(sle_x>0)
18725 2020 sle_x-=16;
18726 else
18727 sle_y+=16;
18728 2020 }
18729 11464 }
18730
18731 // moves sle_x and sle_y to the next available position
18732 // returns the direction the enemy should face
18733 2429 int32_t next_side_pos(int32_t screen, bool random)
18734 {
18735 bool blocked;
18736 2429 int32_t c=0;
18737 25357 auto [offx, offy] = translate_screen_coordinates_to_world(screen);
18738
18739 2429 do
18740 {
18741
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 11333 times.
11464 nsp(c>35 ? false : random);
18742 22928 int x = sle_x + offx;
18743 22928 int y = sle_y + offy;
18744
4/4
✓ Branch 0 taken 2447 times.
✓ Branch 1 taken 9017 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 2428 times.
13892 blocked = _walkflag(x,y,2) || _walkflag(x,y+8,2) ||
18745
1/2
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
2428 (combo_class_buf[COMBOTYPE(x,y)].block_enemies ||
18746
2/4
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2428 times.
✗ Branch 3 not taken.
2428 MAPFLAG(x,y) == mfNOENEMY || MAPCOMBOFLAG(x,y)==mfNOENEMY ||
18747
2/4
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2428 times.
2428 MAPFLAG(x,y) == mfNOGROUNDENEMY || MAPCOMBOFLAG(x,y)==mfNOGROUNDENEMY ||
18748 2428 iswaterex_z3(MAPCOMBO(x,y), -1, x, y, true));
18749
18750
2/2
✓ Branch 0 taken 11463 times.
✓ Branch 1 taken 1 times.
11464 if(++c>50)
18751 1 return -1;
18752
2/2
✓ Branch 0 taken 9035 times.
✓ Branch 1 taken 2428 times.
11463 }
18753 11463 while(blocked);
18754
18755 2428 int32_t dir=0;
18756
18757
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 736 times.
2428 if(sle_x==0) dir=right;
18758
18759
2/2
✓ Branch 0 taken 1859 times.
✓ Branch 1 taken 569 times.
2428 if(sle_y==0) dir=down;
18760
18761
2/2
✓ Branch 0 taken 1720 times.
✓ Branch 1 taken 708 times.
2428 if(sle_x==240) dir=left;
18762
18763
1/2
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
2428 if(sle_y==168) dir=up;
18764
18765 2428 return dir;
18766 2429 }
18767
18768 bool can_side_load(int32_t id)
18769 {
18770 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
18771 {
18772 return false;
18773 }
18774
18775 id = id&0xFFF;
18776
18777 switch(guysbuf[id].type)
18778 {
18779 case eeTEK:
18780 case eeLEV:
18781 case eeAQUA:
18782 case eeDONGO:
18783 case eeMANHAN:
18784 case eeGLEEOK:
18785 case eeDIG:
18786 case eeGHOMA:
18787 case eeLANM:
18788 case eePATRA:
18789 case eeGANON:
18790 case eePROJECTILE:
18791 return false;
18792 break;
18793 }
18794
18795 return true;
18796 }
18797
18798 bool enemy_spawning_has_checked_been_here;
18799 static bool enemy_spawning_has_been_here;
18800
18801 35048 static bool check_if_recently_visited()
18802 {
18803
2/2
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 34526 times.
35048 if (enemy_spawning_has_checked_been_here)
18804 522 return enemy_spawning_has_been_here;
18805
18806 34526 int mi = mapind(cur_map, cur_screen);
18807
18808 34526 enemy_spawning_has_been_here = false;
18809
2/2
✓ Branch 0 taken 207156 times.
✓ Branch 1 taken 34526 times.
241682 for (int i = 0; i < 6; i++)
18810
2/2
✓ Branch 0 taken 197577 times.
✓ Branch 1 taken 9579 times.
216735 if (visited[i] == mi)
18811 9579 enemy_spawning_has_been_here = true;
18812
18813
2/2
✓ Branch 0 taken 9579 times.
✓ Branch 1 taken 24947 times.
34526 if (!enemy_spawning_has_been_here)
18814 {
18815 24947 visited[vhead] = mi; //If not, it adds it to the array,
18816 24947 vhead = (vhead+1)%6; //which overrides one of the others, and then moves onto the next.
18817 24947 }
18818
18819 34526 enemy_spawning_has_checked_been_here = true;
18820 34526 return enemy_spawning_has_been_here;
18821 35048 }
18822
18823 static std::array<bool, MAPSCRS> script_sle;
18824
18825 static int32_t sle_pattern = 0;
18826 static void script_side_load_enemies(mapscr* scr)
18827 {
18828 if (script_sle[scr->screen] || sle_clk) return;
18829
18830 sle_cnt = 0;
18831 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18832 ++sle_cnt;
18833 script_sle[scr->screen] = true;
18834 sle_pattern = scr->pattern;
18835 sle_clk = 0;
18836 }
18837
18838 54516 static void side_load_enemies(mapscr* scr)
18839 {
18840 54516 int screen = scr->screen;
18841
18842
3/4
✓ Branch 0 taken 683 times.
✓ Branch 1 taken 53833 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 683 times.
54516 if (sle_clk==0 && !script_sle[scr->screen])
18843 {
18844 683 sle_pattern = scr->pattern;
18845 683 sle_cnt = 0;
18846 683 int32_t guycnt = 0;
18847
18848 683 int mi = mapind(cur_map, screen);
18849 683 bool reload=true;
18850 683 bool unbeatablereload = true;
18851
18852 683 load_default_enemies(scr);
18853
18854 683 bool beenhere = check_if_recently_visited();
18855
4/4
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 480 times.
✓ Branch 2 taken 161 times.
✓ Branch 3 taken 42 times.
683 if (beenhere && game->guys[mi] == 0)
18856 {
18857 42 sle_cnt=0;
18858 42 reload=false;
18859 42 }
18860
18861
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 641 times.
683 if(reload)
18862 {
18863 641 sle_cnt = game->guys[mi];
18864
18865
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 641 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 221 times.
641 if((get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)
18866 641 || sle_cnt==0)
18867 {
18868
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1272 times.
✓ Branch 2 taken 1054 times.
✓ Branch 3 taken 221 times.
1275 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18869 1054 ++sle_cnt;
18870 221 }
18871
3/4
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 161 times.
✓ Branch 2 taken 480 times.
✗ Branch 3 not taken.
641 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
18872 {
18873 for(int32_t i = 0; i<sle_cnt && scr->enemy[i]>0; i++)
18874 {
18875 if (!(guysbuf[scr->enemy[i]].flags & guy_doesnt_count))
18876 {
18877 unbeatablereload = false;
18878 }
18879 }
18880 if (unbeatablereload)
18881 {
18882 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18883 {
18884 ++sle_cnt;
18885 }
18886 }
18887 }
18888 641 }
18889
18890
3/4
✓ Branch 0 taken 652 times.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 652 times.
683 if((get_qr(qr_ALWAYSRET)) || (scr->flags3&fENEMIESRETURN))
18891 {
18892 31 sle_cnt = 0;
18893
18894
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✓ Branch 2 taken 108 times.
✓ Branch 3 taken 31 times.
139 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18895 108 ++sle_cnt;
18896 31 }
18897
1/2
✓ Branch 0 taken 683 times.
✗ Branch 1 not taken.
683 if(getmapflag(scr, mNO_ENEMIES_RETURN))
18898 sle_cnt = 0;
18899
18900
2/2
✓ Branch 0 taken 2446 times.
✓ Branch 1 taken 683 times.
3129 for(int32_t i=0; i<sle_cnt; i++)
18901 2446 ++guycnt;
18902
18903 683 game->guys[mi] = guycnt;
18904 683 }
18905
18906
2/2
✓ Branch 0 taken 52087 times.
✓ Branch 1 taken 2429 times.
54516 if((++sle_clk+8)%24 == 0)
18907 {
18908 2429 int32_t dir = next_side_pos(screen, sle_pattern==pSIDESR);
18909 6819 auto [x, y] = translate_screen_coordinates_to_world(screen, sle_x, sle_y);
18910
18911
6/6
✓ Branch 0 taken 2428 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 233 times.
✓ Branch 3 taken 2195 times.
✓ Branch 4 taken 233 times.
✓ Branch 5 taken 2195 times.
2429 if(dir==-1 || tooclose(x,y,32))
18912 {
18913 234 return;
18914 }
18915
18916 2195 int32_t enemy_slot=guys.Count();
18917
18918
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2195 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2195 times.
2195 while(sle_cnt > 0 && !ok2add(scr, scr->enemy[sle_cnt-1]))
18919 sle_cnt--;
18920
18921
1/2
✓ Branch 0 taken 2195 times.
✗ Branch 1 not taken.
2195 if(sle_cnt > 0)
18922 {
18923
3/6
✓ Branch 0 taken 2195 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2195 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2195 times.
✗ Branch 5 not taken.
6585 if(addenemy(screen, x,y,scr->enemy[--sle_cnt],0))
18924 {
18925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2195 times.
2195 if (((enemy*)guys.spr(enemy_slot))->type != eeTEK)
18926 {
18927 2195 guys.spr(enemy_slot)->dir = dir;
18928 2195 }
18929
1/2
✓ Branch 0 taken 2195 times.
✗ Branch 1 not taken.
2195 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
18930 {
18931 if (!FFCore.system_suspend[susptNPCSCRIPTS])
18932 {
18933 guys.spr(enemy_slot)->run_script(MODE_NORMAL);
18934 ((enemy*)guys.spr(enemy_slot))->didScriptThisFrame = true;
18935 }
18936 }
18937 2195 }
18938 2195 }
18939 2195 }
18940
18941
2/2
✓ Branch 0 taken 53704 times.
✓ Branch 1 taken 578 times.
54282 if(sle_cnt<=0)
18942 {
18943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 578 times.
578 if (script_sle[screen])
18944 script_sle[screen] = false;
18945 else
18946 {
18947 578 get_screen_state(screen).loaded_enemies = true;
18948 }
18949 578 sle_clk = 0;
18950 578 }
18951 54516 }
18952
18953 1253524 bool is_starting_pos(mapscr* scr, int32_t i, int32_t x, int32_t y, int32_t t)
18954 {
18955
2/2
✓ Branch 0 taken 116388 times.
✓ Branch 1 taken 1137136 times.
1253524 if (!is_in_scrolling_region())
18956
2/4
✓ Branch 0 taken 1137136 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1137136 times.
1137136 if(scr->enemy[i]<1||scr->enemy[i]>=MAXGUYS) //Hackish fix for crash in Waterford.st on screen 0x65 of dmap 0 (map 1).
18957 {
18958 return false; //never 0, never OoB.
18959 }
18960 // No corner enemies
18961
6/6
✓ Branch 0 taken 1082517 times.
✓ Branch 1 taken 171007 times.
✓ Branch 2 taken 41285 times.
✓ Branch 3 taken 1123802 times.
✓ Branch 4 taken 117940 times.
✓ Branch 5 taken 94352 times.
1253524 if ((x==0 || x==world_w-16) && (y==0 || y==world_h-16))
18962 212292 return false;
18963
18964 //Is a no spawn combo...
18965
4/4
✓ Branch 0 taken 1123788 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 1123794 times.
1123802 if(MAPFLAG(x+8,y+8)==mfNOENEMYSPAWN || MAPCOMBOFLAG(x+8,y+8)==mfNOENEMYSPAWN)
18966 20 return false;
18967
18968 // No enemies in dungeon walls
18969
2/2
✓ Branch 0 taken 468705 times.
✓ Branch 1 taken 655089 times.
1123794 if (isdungeon(scr->screen))
18970 {
18971 655089 auto [offx, offy] = translate_screen_coordinates_to_world(scr->screen);
18972
17/18
✓ Branch 0 taken 655089 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 582529 times.
✓ Branch 3 taken 72560 times.
✓ Branch 4 taken 582529 times.
✓ Branch 5 taken 72560 times.
✓ Branch 6 taken 509969 times.
✓ Branch 7 taken 72560 times.
✓ Branch 8 taken 509969 times.
✓ Branch 9 taken 72560 times.
✓ Branch 10 taken 422897 times.
✓ Branch 11 taken 87072 times.
✓ Branch 12 taken 422897 times.
✓ Branch 13 taken 87072 times.
✓ Branch 14 taken 87072 times.
✓ Branch 15 taken 335825 times.
✓ Branch 16 taken 87072 times.
✓ Branch 17 taken 335825 times.
655089 if(isdungeon(scr->screen) && (x<32+offx || x>=224+offx || y<32+offy || y>=144+offy))
18973 319264 return false;
18974 335825 }
18975
18976 // Too close to hero
18977
4/4
✓ Branch 0 taken 77038 times.
✓ Branch 1 taken 727492 times.
✓ Branch 2 taken 101 times.
✓ Branch 3 taken 76937 times.
804530 if(tooclose(x,y,40) && t<11)
18978 76937 return false;
18979
18980 // Can't fly onto it?
18981
4/4
✓ Branch 0 taken 139611 times.
✓ Branch 1 taken 587982 times.
✓ Branch 2 taken 35960 times.
✓ Branch 3 taken 25255 times.
788808 if(isflier(scr->enemy[i])&&
18982
2/2
✓ Branch 0 taken 139221 times.
✓ Branch 1 taken 390 times.
139611 (flyerblocked(x+8,y+8,spw_floater,guysbuf[scr->enemy[i]])||
18983
2/2
✓ Branch 0 taken 61215 times.
✓ Branch 1 taken 78006 times.
139221 (_walkflag(x,y+8,2)&&!get_qr(qr_WALLFLIERS))))
18984 25645 return false;
18985
18986 // Can't jump onto it?
18987 if
18988 (
18989
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 88704 times.
790656 guysbuf[scr->enemy[i]].type==eeTEK
18990
18991
2/2
✓ Branch 0 taken 88722 times.
✓ Branch 1 taken 613226 times.
701948 &&
18992 (
18993
2/2
✓ Branch 0 taken 88715 times.
✓ Branch 1 taken 7 times.
88722 COMBOTYPE(x+8,y+8)==cNOJUMPZONE||
18994
2/2
✓ Branch 0 taken 88714 times.
✓ Branch 1 taken 1 times.
88715 COMBOTYPE(x+8,y+8)==cNOENEMY||
18995
1/2
✓ Branch 0 taken 88714 times.
✗ Branch 1 not taken.
88714 ispitfall(x+8,y+8)||
18996
2/2
✓ Branch 0 taken 88708 times.
✓ Branch 1 taken 6 times.
88714 MAPFLAG(x+8,y+8)==mfNOENEMY||
18997 88708 MAPCOMBOFLAG(x+8,y+8)==mfNOENEMY
18998 )
18999 )
19000 {
19001 18 return false;
19002 }
19003
19004 // Other off-limit combos
19005
6/6
✓ Branch 0 taken 587958 times.
✓ Branch 1 taken 113972 times.
✓ Branch 2 taken 499254 times.
✓ Branch 3 taken 88704 times.
✓ Branch 4 taken 276494 times.
✓ Branch 5 taken 222760 times.
1201184 if((!isflier(scr->enemy[i])&& guysbuf[scr->enemy[i]].type!=eeTEK &&
19006
2/2
✓ Branch 0 taken 282052 times.
✓ Branch 1 taken 217202 times.
499254 (_walkflag(x,y+8,2) || groundblocked(x+8,y+8,guysbuf[scr->enemy[i]]))) &&
19007 499254 guysbuf[scr->enemy[i]].type!=eeZORA)
19008 222760 return false;
19009
19010 // Don't ever generate enemies on these combos!
19011
4/4
✓ Branch 0 taken 478864 times.
✓ Branch 1 taken 306 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 478870 times.
479170 if(COMBOTYPE(x+8,y+8)==cARMOS||COMBOTYPE(x+8,y+8)==cBSGRAVE)
19012 312 return false;
19013
19014 //BS Dodongos need at least 2 spaces.
19015
4/4
✓ Branch 0 taken 1039 times.
✓ Branch 1 taken 477831 times.
✓ Branch 2 taken 1014 times.
✓ Branch 3 taken 25 times.
478870 if ((guysbuf[scr->enemy[i]].type==eeDONGO)&&(guysbuf[scr->enemy[i]].attributes[9] == 1))
19016 {
19017
3/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19 times.
25 if(((x<16) ||_walkflag(x-16,y+8, 2))&&
19018
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 ((x>224)||_walkflag(x+16,y+8, 2))&&
19019
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
6 ((y<16) ||_walkflag(x, y-8, 2))&&
19020 ((y>144)||_walkflag(x, y+24,2)))
19021 {
19022 return false;
19023 }
19024 19 }
19025
19026 478864 return true;
19027 1147384 }
19028
19029 160640 bool is_ceiling_pattern(int32_t i)
19030 {
19031
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 160620 times.
160640 return (i==pCEILING || i==pCEILINGR);
19032 }
19033
19034 5955 rpos_t placeenemy(mapscr* scr, int32_t i, int32_t offx, int32_t offy)
19035 {
19036 5955 std::vector<rpos_t> freeposcache;
19037
19038
2/2
✓ Branch 0 taken 65505 times.
✓ Branch 1 taken 5955 times.
71460 for(int32_t y=offy; y<offy+176; y+=16)
19039 {
19040
2/2
✓ Branch 0 taken 1048080 times.
✓ Branch 1 taken 65505 times.
1113585 for(int32_t x=offx; x<offx+256; x+=16)
19041 {
19042
3/4
✓ Branch 0 taken 1048080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 421055 times.
✓ Branch 3 taken 627025 times.
1048080 if(is_starting_pos(scr,i,x,y,0))
19043 {
19044
2/4
✓ Branch 0 taken 421055 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 421055 times.
✗ Branch 3 not taken.
421055 freeposcache.push_back(COMBOPOS_REGION(x, y));
19045 421055 }
19046 1048080 }
19047 65505 }
19048
19049
2/2
✓ Branch 0 taken 5944 times.
✓ Branch 1 taken 11 times.
5955 if (!freeposcache.empty())
19050
1/2
✓ Branch 0 taken 5944 times.
✗ Branch 1 not taken.
5944 return freeposcache[zc_oldrand()%freeposcache.size()];
19051
19052 11 return rpos_t::None;
19053 5955 }
19054
19055 81131 void spawnEnemy(mapscr* scr, int& pos, int& clk, int offx, int offy, int& fastguys, int& i, int& guycnt, int& loadcnt)
19056 {
19057 81131 int screen = scr->screen;
19058 81131 int x = 0;
19059 81131 int y = 0;
19060 81131 bool placed=false;
19061 81131 int32_t t=-1;
19062
19063 // First: enemy combo flags
19064
2/2
✓ Branch 0 taken 805424 times.
✓ Branch 1 taken 63764 times.
869188 for(int32_t sy=0; sy<176; sy+=16)
19065 {
19066
2/2
✓ Branch 0 taken 12757620 times.
✓ Branch 1 taken 788057 times.
13545677 for(int32_t sx=0; sx<256; sx+=16)
19067 {
19068 12757620 x = offx + sx;
19069 12757620 y = offy + sy;
19070 12757620 int32_t cflag = MAPFLAG(x, y);
19071 12757620 int32_t cflag_i = MAPCOMBOFLAG(x, y);
19072
19073
2/4
✓ Branch 0 taken 12757620 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12757620 times.
✗ Branch 3 not taken.
12757620 if(((cflag==mfENEMYALL)||(cflag_i==mfENEMYALL)) && (!placed))
19074 {
19075 if(!ok2add(scr, scr->enemy[i]))
19076 {
19077 if (loadcnt < 10 && scr->enemy[i] > 0 && scr->enemy[i] < MAXGUYS) ++loadcnt;
19078 }
19079 else
19080 {
19081 addenemy_z(screen,x,
19082 (is_ceiling_pattern(scr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19083 (is_ceiling_pattern(scr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,scr->enemy[i],-15);
19084
19085 ++guycnt;
19086
19087 placed=true;
19088 goto placed_enemy;
19089 }
19090 }
19091
19092
4/4
✓ Branch 0 taken 12740204 times.
✓ Branch 1 taken 17416 times.
✓ Branch 2 taken 12740204 times.
✓ Branch 3 taken 17416 times.
12757620 else if(((cflag==mfENEMY0+i)||(cflag_i==mfENEMY0+i)) && (!placed))
19093 {
19094
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 17367 times.
17416 if(!ok2add(scr, scr->enemy[i]))
19095 {
19096
4/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 37 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
49 if (loadcnt < 10 && scr->enemy[i] > 0 && scr->enemy[i] < MAXGUYS) ++loadcnt;
19097 49 }
19098 else
19099 {
19100 34734 addenemy_z(screen,x,
19101
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17366 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
17367 (is_ceiling_pattern(scr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19102
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17366 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
17367 (is_ceiling_pattern(scr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,scr->enemy[i],-15);
19103
19104 17367 ++guycnt;
19105
19106 17367 placed=true;
19107 17367 goto placed_enemy;
19108 }
19109 49 }
19110 12740253 }
19111 788057 }
19112
19113 // Next: enemy pattern
19114
6/8
✓ Branch 0 taken 4997 times.
✓ Branch 1 taken 58767 times.
✓ Branch 2 taken 58030 times.
✓ Branch 3 taken 5734 times.
✓ Branch 4 taken 58030 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 58030 times.
63764 if((scr->pattern==pRANDOM || scr->pattern==pCEILING) && !(isSideViewGravity()) && ((scr->enemy[i]>0&&scr->enemy[i]<MAXGUYS)))
19115 {
19116 58030 do
19117 {
19118
19119 // NES positions
19120 99525 pos%=9;
19121 99525 x=offx+stx[loadside][pos];
19122 99525 y=offy+sty[loadside][pos];
19123 99525 ++pos;
19124 99525 ++t;
19125
2/2
✓ Branch 0 taken 41495 times.
✓ Branch 1 taken 58030 times.
157555 }
19126
2/2
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 99304 times.
99525 while((t< 20) && !is_starting_pos(scr,i,x,y,t));
19127 58030 }
19128
19129
4/4
✓ Branch 0 taken 58030 times.
✓ Branch 1 taken 5734 times.
✓ Branch 2 taken 221 times.
✓ Branch 3 taken 57809 times.
63764 if(t<0 || t >= 20) // above enemy pattern failed
19130 {
19131 // Final chance: find a random position anywhere onscreen
19132 5955 rpos_t rand_rpos = placeenemy(scr, i, offx, offy);
19133
19134
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5944 times.
5955 if (rand_rpos != rpos_t::None)
19135 {
19136 5944 std::tie(x, y) = COMBOXY_REGION(rand_rpos);
19137 5944 }
19138 else // All opportunities failed - abort
19139 {
19140 11 return;
19141 }
19142 5944 }
19143
19144 {
19145 63753 int32_t c=0;
19146 63753 c=clk;
19147
19148
2/2
✓ Branch 0 taken 9643 times.
✓ Branch 1 taken 54110 times.
63753 if(!slowguy(scr->enemy[i]))
19149 54110 ++fastguys;
19150
2/2
✓ Branch 0 taken 1586 times.
✓ Branch 1 taken 8057 times.
9643 else if(fastguys>0)
19151 1586 c=-15*(i-fastguys+2);
19152 else
19153 8057 c=-15*(i+1);
19154
19155
4/6
✓ Branch 0 taken 29160 times.
✓ Branch 1 taken 34593 times.
✓ Branch 2 taken 29160 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29160 times.
63753 if(BSZ&&((scr->enemy[i]>0&&scr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19156 {
19157 // Special case for blue leevers
19158
4/4
✓ Branch 0 taken 1894 times.
✓ Branch 1 taken 27266 times.
✓ Branch 2 taken 761 times.
✓ Branch 3 taken 1133 times.
29160 if(guysbuf[scr->enemy[i]].type==eeLEV && guysbuf[scr->enemy[i]].attributes[0] == 1)
19159 761 c=-15*(i+1);
19160 else
19161 28399 c=-15;
19162 29160 }
19163
19164
2/2
✓ Branch 0 taken 62953 times.
✓ Branch 1 taken 800 times.
63753 if(!ok2add(scr, scr->enemy[i]))
19165 {
19166
4/6
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 670 times.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 130 times.
800 if (loadcnt < 10 && scr->enemy[i] > 0 && scr->enemy[i] < MAXGUYS) ++loadcnt;
19167 800 }
19168 else
19169 {
19170
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62953 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62953 if(((scr->enemy[i]>0||scr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19171 {
19172
3/4
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 62777 times.
✓ Branch 2 taken 176 times.
✗ Branch 3 not taken.
125906 addenemy_z(screen,x,(is_ceiling_pattern(scr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19173
3/4
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 62777 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 176 times.
62953 (is_ceiling_pattern(scr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,scr->enemy[i],c);
19174
19175 62953 ++guycnt;
19176 62953 }
19177 }
19178
19179 63753 placed=true;
19180 63753 } // if(t < 20)
19181
19182 placed_enemy:
19183
19184 // I don't like this, but it seems to work...
19185 static bool foundCarrier;
19186
19187
2/2
✓ Branch 0 taken 59508 times.
✓ Branch 1 taken 21612 times.
81120 if(i==0)
19188 21612 foundCarrier=false;
19189
19190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81120 times.
81120 if(placed)
19191 {
19192
4/4
✓ Branch 0 taken 21612 times.
✓ Branch 1 taken 59508 times.
✓ Branch 2 taken 21443 times.
✓ Branch 3 taken 169 times.
81120 if(i==0 && scr->flags11&efLEADER)
19193 {
19194 169 enemy* e = find_guy_first_for_id(screen, scr->enemy[i], 0xFFF);
19195
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 7 times.
169 if (e)
19196 {
19197 //grab the first segment. Not accurate to how older versions did it, but the way they did it might be incompatible with enemy editor.
19198
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
162 if ((e->type == eeLANM) && !get_qr(qr_NO_LANMOLA_RINGLEADER))
19199 {
19200 e = find_guy_nth_for_id(screen, scr->enemy[i], 2, 0xFFF);
19201 }
19202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
162 if (e)
19203 {
19204 162 e->leader = true;
19205 162 }
19206 162 }
19207 169 }
19208
19209 81120 ScreenItemState item_state = get_screen_state(screen).item_state;
19210
5/6
✓ Branch 0 taken 80878 times.
✓ Branch 1 taken 242 times.
✓ Branch 2 taken 80878 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77 times.
✓ Branch 5 taken 80801 times.
81120 if (!foundCarrier && (item_state == ScreenItemState::CarriedByEnemy || item_state == ScreenItemState::MustGiveToEnemy))
19211 {
19212 77 enemy* e = find_guy_first_for_id(screen, scr->enemy[i], 0xFFF);
19213
2/4
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 77 times.
77 if (e && (e->flags&guy_doesnt_count)==0)
19214 {
19215 77 e->itemguy = true;
19216 77 foundCarrier=true;
19217 77 }
19218 77 }
19219 81120 }
19220 81131 }
19221
19222 // returns index of first sprite with matching id, -1 if none found
19223 246 enemy* find_guy_first_for_id(int screen, int id, int mask)
19224 {
19225 246 int count = guys.Count();
19226
2/2
✓ Branch 0 taken 366 times.
✓ Branch 1 taken 7 times.
373 for (int32_t i=0; i<count; i++)
19227 {
19228 366 enemy* e = (enemy*)guys.spr(i);
19229
4/4
✓ Branch 0 taken 318 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 239 times.
✓ Branch 3 taken 79 times.
366 if (e->screen_spawned == screen && (e->id&mask) == (id&mask))
19230 {
19231 239 return e;
19232 }
19233 127 }
19234
19235 7 return nullptr;
19236 246 }
19237
19238 enemy* find_guy_nth_for_id(int screen, int id, int n, int mask)
19239 {
19240 int count = guys.Count();
19241 for(int32_t i=0; i<count; i++)
19242 {
19243 enemy* e = (enemy*)guys.spr(i);
19244 if (e->screen_spawned == screen && (e->id&mask) == (id&mask))
19245 {
19246 if (n > 1) --n;
19247 else return e;
19248 }
19249 }
19250 return nullptr;
19251 }
19252
19253 bool scriptloadenemies(int screen)
19254 {
19255 // https://discord.com/channels/876899628556091432/1395904851908755577
19256 bool replay_compat_enemies_load_bug = replay_is_active() && replay_get_meta_bool("compat_scriptloadenemies");
19257 auto& state = get_screen_state(screen);
19258 if (!replay_compat_enemies_load_bug)
19259 state.loaded_enemies = true;
19260
19261 if (sle_clk || script_sle[screen]) return false;
19262
19263 mapscr* scr = get_scr(screen);
19264 if(scr->pattern==pNOSPAWN) return false;
19265
19266 if(scr->pattern==pSIDES || scr->pattern==pSIDESR)
19267 {
19268 script_side_load_enemies(scr);
19269 return true;
19270 }
19271
19272 auto [x, y] = translate_screen_coordinates_to_world(screen);
19273 int32_t pos=zc_oldrand()%9;
19274 int32_t clk=-15,fastguys=0;
19275 int32_t i=0,guycnt=0;
19276 int32_t loadcnt = 10;
19277
19278 for(; i<loadcnt && scr->enemy[i]>0; i++)
19279 {
19280 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
19281 spawnEnemy(scr, pos, clk, x, y, fastguys, i, guycnt, loadcnt);
19282 if (guys.Count() > preguycount)
19283 {
19284 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19285 {
19286 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19287 {
19288 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19289 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19290 }
19291 }
19292 }
19293 --clk;
19294 }
19295 return true;
19296 }
19297
19298 14267721 void loadenemies()
19299 {
19300 28915600 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
19301 14647879 int screen = scr->screen;
19302 14647879 auto& state = get_screen_state(screen);
19303
2/2
✓ Branch 0 taken 14232652 times.
✓ Branch 1 taken 415227 times.
14647879 if (state.loaded_enemies)
19304 14232652 return;
19305
19306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415227 times.
415227 if(getmapflag(scr, mNO_ENEMIES_RETURN))
19307 return;
19308
19309 // dungeon basements
19310 static byte dngn_enemy_x[4] = {32,96,144,208};
19311
2/2
✓ Branch 0 taken 148964 times.
✓ Branch 1 taken 266263 times.
415227 if (cur_screen>=128)
19312 {
19313
2/2
✓ Branch 0 taken 148489 times.
✓ Branch 1 taken 475 times.
148964 if(DMaps[cur_dmap].flags&dmfCAVES) return;
19314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 475 times.
475 if ( DMaps[cur_dmap].flags&dmfNEWCELLARENEMIES )
19315 {
19316 for(int32_t i=0; i<10; i++)
19317 {
19318 if ( scr->enemy[i] )
19319 {
19320 int32_t preguycount = guys.Count();
19321 addenemy(screen,dngn_enemy_x[i],96,scr->enemy[i],-14-i);
19322 if (guys.Count() > preguycount)
19323 {
19324 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19325 {
19326 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19327 {
19328 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19329 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19330 }
19331 }
19332 }
19333 }
19334 }
19335 }
19336 else
19337 {
19338
2/2
✓ Branch 0 taken 1900 times.
✓ Branch 1 taken 475 times.
2375 for(int32_t i=0; i<4; i++)
19339 {
19340 1900 int32_t preguycount = guys.Count();
19341
2/2
✓ Branch 0 taken 1044 times.
✓ Branch 1 taken 856 times.
1900 addenemy(screen,dngn_enemy_x[i],96,scr->enemy[i]?scr->enemy[i]:(int32_t)eKEESE1,-14-i);
19342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1900 times.
1900 if (guys.Count() > preguycount)
19343 {
19344
2/2
✓ Branch 0 taken 1896 times.
✓ Branch 1 taken 4 times.
1900 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19345 {
19346
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19347 {
19348 4 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19349 4 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19350 4 }
19351 4 }
19352 1900 }
19353 1900 }
19354 }
19355
19356 475 state.loaded_enemies = true;
19357 475 return;
19358 }
19359
19360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 266263 times.
266263 if (scr->pattern == pNOSPAWN)
19361 return;
19362
19363 // TODO: configure when screen enemies spawn.
19364
2/2
✓ Branch 0 taken 88971 times.
✓ Branch 1 taken 177292 times.
266263 if (!viewport.intersects_with(region_scr_x*256, region_scr_y*176, 256, 176))
19365 177292 return;
19366
19367
4/4
✓ Branch 0 taken 50524 times.
✓ Branch 1 taken 38447 times.
✓ Branch 2 taken 16069 times.
✓ Branch 3 taken 34455 times.
88971 if (scr->pattern==pSIDES || scr->pattern==pSIDESR)
19368 {
19369 54516 side_load_enemies(scr);
19370 54516 return;
19371 }
19372
19373 34455 state.loaded_enemies = true;
19374
19375 // check if it's the dungeon boss and it has been beaten before
19376
4/4
✓ Branch 0 taken 359 times.
✓ Branch 1 taken 34096 times.
✓ Branch 2 taken 269 times.
✓ Branch 3 taken 90 times.
34455 if (scr->flags11&efBOSS && game->lvlitems[dlevel]&(1 << li_boss_killed))
19377 90 return;
19378
19379 34365 int32_t loadcnt = 10;
19380 34365 int16_t mi = mapind(cur_map, screen);
19381 34365 bool beenhere = check_if_recently_visited();
19382
19383 //Okay so this basically checks the last 6 unique screen's you've been in and checks if the current screen is one of them.
19384 34365 bool reload = true;
19385
4/4
✓ Branch 0 taken 9722 times.
✓ Branch 1 taken 24643 times.
✓ Branch 2 taken 4708 times.
✓ Branch 3 taken 5014 times.
34365 if (beenhere && game->guys[mi] == 0) //Then, if you have been here, and the number of enemies left on the screen is 0,
19386 {
19387 5014 loadcnt = 0; //It will tell it not to load any enemies,
19388 5014 reload = false; //both by setting loadcnt to 0 and making the reload if statement not run.
19389 5014 }
19390
19391 34365 bool unbeatablereload = true;
19392
2/2
✓ Branch 0 taken 5014 times.
✓ Branch 1 taken 29351 times.
34365 if(reload) //This if statement is only false if this screen is one of the last 6 screens you visited and you left 0 enemies alive.
19393 {
19394 29351 loadcnt = game->guys[mi]; //Otherwise, if this if statement is true, it will try to load the last amount of enemies you left alive.
19395
19396
2/4
✓ Branch 0 taken 10289 times.
✓ Branch 1 taken 19062 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
29351 if(loadcnt==0 || //Then, if the number of enemies is 0, that means you left 0 enemies alive on a screen but haven't been there in the past 6 screens.
19397
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10289 times.
10289 (get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)) //Alternatively, if you have the quest rule enabled that always respawns all enemies after a period of time, and you haven't been here in 6 screens.
19398 19062 loadcnt = 10; //That means all enemies need to be respawned.
19399
3/4
✓ Branch 0 taken 24643 times.
✓ Branch 1 taken 4708 times.
✓ Branch 2 taken 24643 times.
✗ Branch 3 not taken.
29351 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
19400 {
19401 for(int32_t i = 0; i<loadcnt && scr->enemy[i]>0; i++)
19402 {
19403 if (!(guysbuf[scr->enemy[i]].flags & guy_doesnt_count))
19404 {
19405 unbeatablereload = false;
19406 }
19407 }
19408 if (unbeatablereload)
19409 {
19410 loadcnt = 10;
19411 }
19412 }
19413 29351 }
19414
19415
4/4
✓ Branch 0 taken 32904 times.
✓ Branch 1 taken 1461 times.
✓ Branch 2 taken 193 times.
✓ Branch 3 taken 32711 times.
34365 if((get_qr(qr_ALWAYSRET)) || (scr->flags3&fENEMIESRETURN)) //If enemies always return is enabled quest-wide or for this screen,
19416 1654 loadcnt = 10; //All enemies also need to be respawned.
19417
19418 // do enemies that are always loaded
19419 34365 load_default_enemies(scr);
19420 34365 activate_fireball_statues(scr);
19421
19422 34365 int32_t pos=zc_oldrand()%9; //This sets up a variable for spawnEnemy to edit so as to spawn the enemies pseudo-randomly.
19423 34365 int32_t clk=-15,fastguys=0; //clk being negative means the enemy is in it's spawn poof.
19424 34365 int32_t i=0,guycnt=0; //Lastly, resets guycnt to 0 so spawnEnemy can increment it manually per-enemy.
19425
4/4
✓ Branch 0 taken 15156 times.
✓ Branch 1 taken 100340 times.
✓ Branch 2 taken 81131 times.
✓ Branch 3 taken 34365 times.
115496 for(; i<loadcnt && scr->enemy[i]>0; i++)
19426 {
19427 81131 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
19428 81131 spawnEnemy(scr, pos, clk, region_scr_x*256, region_scr_y*176, fastguys, i, guycnt, loadcnt);
19429
2/2
✓ Branch 0 taken 811 times.
✓ Branch 1 taken 80320 times.
81131 if (guys.Count() > preguycount)
19430 {
19431
2/2
✓ Branch 0 taken 77968 times.
✓ Branch 1 taken 2352 times.
80320 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19432 {
19433
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2348 times.
2352 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19434 {
19435 2348 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19436 2348 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19437 2348 }
19438 2352 }
19439 80320 }
19440
19441 81131 --clk; //Each additional enemy spawns with a slightly longer spawn poof than the previous.
19442 81131 }
19443
19444 34365 game->guys[mi] = guycnt;
19445 14647879 });
19446 14267721 }
19447
19448 233 void moneysign()
19449 {
19450 466 auto [dx, dy] = translate_screen_coordinates_to_world(cur_screen);
19451 466 additem(dx+48,dy+108,iRupy,ipDUMMY);
19452 233 set_clip_state(pricesdisplaybuf, 0);
19453 233 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),"X",64,112,CSET(0)+1,-1);
19454 233 }
19455
19456 3303 void putprices(bool sign)
19457 {
19458
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 3271 times.
3303 if(fadeclk > 0) return;
19459
19460 3271 rectfill(pricesdisplaybuf, 72, 112, pricesdisplaybuf->w-1, pricesdisplaybuf->h-1, 0);
19461 3271 int32_t step=32;
19462 3271 int32_t x=80;
19463
19464
2/2
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 2990 times.
3271 if(prices[2]==0)
19465 {
19466 2990 step<<=1;
19467
19468
2/2
✓ Branch 0 taken 2958 times.
✓ Branch 1 taken 32 times.
2990 if(prices[1]==0)
19469 {
19470 2958 x=112;
19471 2958 }
19472 2990 }
19473
19474
2/2
✓ Branch 0 taken 3271 times.
✓ Branch 1 taken 9813 times.
13084 for(int32_t i=0; i<3; i++)
19475 {
19476 // Kind of stupid, but it works: 100000 is used to indicate that an item
19477 // has a price of zero rather than there being no item.
19478 // 100000 isn't a valid price, so this doesn't cause problems.
19479
3/4
✓ Branch 0 taken 1039 times.
✓ Branch 1 taken 8774 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1039 times.
9813 if(prices[i]!=0 && prices[i]<100000)
19480 {
19481 char buf[8];
19482 1039 sprintf(buf,sign?"%+3d":"%3d",prices[i]);
19483
19484 1039 int32_t l=(int32_t)strlen(buf);
19485 1039 set_clip_state(pricesdisplaybuf, 0);
19486
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 1012 times.
1039 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),buf,x-(l>3?(l-3)<<3:0),112,CSET(0)+1,-1);
19487 1039 }
19488
19489 9813 x+=step;
19490 9813 }
19491 3303 }
19492
19493 // Setting up special rooms
19494 // Also called when the Letter is used successfully.
19495 1210 void setupscreen()
19496 {
19497 1210 boughtsomething=false;
19498
19499 // Either the origin screen, or if in a 0x80 room the screen player came from.
19500
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 794 times.
1210 mapscr* base_scr = cur_screen >= 128 ? special_warp_return_scr : origin_scr;
19501 1210 mapscr* scr = origin_scr;
19502
19503 1210 word str=base_scr->str;
19504
19505 2262 auto [dx, dy] = translate_screen_coordinates_to_world(scr->screen);
19506
19507 // Prices are already set to 0 in dowarp()
19508
14/15
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 689 times.
✓ Branch 2 taken 164 times.
✓ Branch 3 taken 28 times.
✓ Branch 4 taken 44 times.
✓ Branch 5 taken 11 times.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 17 times.
✓ Branch 10 taken 32 times.
✓ Branch 11 taken 1 times.
✓ Branch 12 taken 19 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 14 times.
1210 switch(base_scr->room)
19509 {
19510 case rSP_ITEM: // special item
19511 328 additem(dx+120,dy+89,base_scr->catchall,ipONETIME2+ipHOLDUP+ipCHECK | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0));
19512 164 break;
19513
19514 case rINFO: // pay for info
19515 {
19516 28 int32_t count = 0;
19517 28 int32_t base = 88;
19518 28 int32_t step = 5;
19519
19520 28 moneysign();
19521
19522
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 84 times.
112 for(int32_t i=0; i<3; i++)
19523 {
19524
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(QMisc.info[base_scr->catchall].str[i])
19525 {
19526 84 ++count;
19527 84 }
19528 else
19529 break;
19530 84 }
19531
19532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(count)
19533 {
19534
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(count==1)
19535 {
19536 base = 88+32;
19537 }
19538
19539
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(count==2)
19540 {
19541 step = 6;
19542 }
19543
19544
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 28 times.
112 for(int32_t i=0; i < count; i++)
19545 {
19546 84 additem((i << step)+base, 89, iRupy, ipMONEY + ipDUMMY);
19547 84 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
19548 84 prices[i] = -(QMisc.info[base_scr->catchall].price[i]);
19549
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(prices[i]==0)
19550 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19551 84 int32_t itemid = current_item_id(itype_wealthmedal);
19552
19553
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
84 if(itemid>=0 && prices[i]!=100000)
19554 {
19555 if(itemsbuf[itemid].flags & item_flag1)
19556 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
19557 else
19558 prices[i]-=itemsbuf[itemid].misc1;
19559 prices[i]=vbound(prices[i], -99999, 0);
19560 if(prices[i]==0)
19561 prices[i]=100000;
19562 }
19563
19564
2/6
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
84 if((QMisc.info[base_scr->catchall].price[i])>1 && prices[i]>-1 && prices[i]!=100000)
19565 prices[i]=-1;
19566 84 }
19567 28 }
19568
19569 28 break;
19570 }
19571
19572 case rMONEY: // secret money
19573 88 additem(dx+120,dy+89,iRupy,ipONETIME+ipDUMMY+ipMONEY);
19574 44 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19575 44 break;
19576
19577 case rGAMBLE: // gambling
19578 11 prices[0]=prices[1]=prices[2]=-10;
19579 11 moneysign();
19580 22 additem(dx+88,dy+89,iRupy,ipMONEY+ipDUMMY);
19581 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19582 22 additem(dx+120,dy+89,iRupy,ipMONEY+ipDUMMY);
19583 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19584 22 additem(dx+152,dy+89,iRupy,ipMONEY+ipDUMMY);
19585 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 2;
19586 11 break;
19587
19588 case rREPAIR: // door repair
19589
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 setmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
19590 // }
19591 13 repaircharge=base_scr->catchall;
19592 13 break;
19593
19594 case rMUPGRADE: // upgrade magic
19595 2 adjustmagic=true;
19596 2 break;
19597
19598 case rLEARNSLASH: // learn slash attack
19599 2 learnslash=true;
19600 2 break;
19601
19602 case rRP_HC: // heart container or red potion
19603 34 additem(dx+88,dy+89,iRPotion,ipONETIME2+ipHOLDUP+ipFADE);
19604 17 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19605 34 additem(dx+152,dy+89,iHeartC,ipONETIME2+ipHOLDUP+ipFADE);
19606 17 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19607 17 break;
19608
19609 case rP_SHOP: // potion shop
19610
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 20 times.
32 if(current_item(itype_letter)<i_letter_used)
19611 {
19612 12 str=0;
19613 12 break;
19614 }
19615
19616 [[fallthrough]];
19617 case rTAKEONE: // take one
19618 case rSHOP: // shop
19619 {
19620 194 int32_t count = 0;
19621 194 int32_t base = 88;
19622 194 int32_t step = 5;
19623
19624
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 193 times.
194 if(base_scr->room != rTAKEONE)
19625 193 moneysign();
19626
19627 //count and align the stuff
19628
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 560 times.
717 for(int32_t i=0; i<3; ++i)
19629 {
19630
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 37 times.
560 if(QMisc.shop[base_scr->catchall].hasitem[count] != 0)
19631 {
19632 523 ++count;
19633 523 }
19634 else
19635 {
19636 37 break;
19637 }
19638 523 }
19639
19640
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 22 times.
194 if(count==1)
19641 {
19642 22 base = 88+32;
19643 22 }
19644
19645
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 15 times.
194 if(count==2)
19646 {
19647 15 step = 6;
19648 15 }
19649
19650
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 194 times.
717 for(int32_t i=0; i<count; i++)
19651 {
19652 1046 additem(dx+(i<<step)+base, dy+89, QMisc.shop[base_scr->catchall].item[i], ipHOLDUP+ipFADE+(base_scr->room == rTAKEONE ? ipONETIME2 : ipCHECK));
19653 523 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
19654
19655
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 521 times.
523 if(base_scr->room != rTAKEONE)
19656 {
19657 521 prices[i] = QMisc.shop[base_scr->catchall].price[i];
19658
1/2
✓ Branch 0 taken 521 times.
✗ Branch 1 not taken.
521 if(prices[i]==0)
19659 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19660 521 int32_t itemid = current_item_id(itype_wealthmedal);
19661
19662
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
521 if(itemid>=0 && prices[i]!=100000)
19663 {
19664
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(itemsbuf[itemid].flags & item_flag1)
19665 9 prices[i]=((prices[i]*itemsbuf[itemid].misc1) / 100);
19666 else
19667 prices[i]+=itemsbuf[itemid].misc1;
19668 9 prices[i]=vbound(prices[i], 0, 99999);
19669
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(prices[i]==0)
19670 prices[i]=100000;
19671 9 }
19672
19673
2/4
✓ Branch 0 taken 521 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 521 times.
✗ Branch 3 not taken.
521 if((QMisc.shop[base_scr->catchall].price[i])>1 && prices[i]<1)
19674 prices[i]=1;
19675 521 }
19676 523 }
19677
19678 194 break;
19679 }
19680 case rBOTTLESHOP: // bottle shop
19681 {
19682 1 int32_t count = 0;
19683 1 int32_t base = 88;
19684 1 int32_t step = 5;
19685
19686 1 moneysign();
19687 1 bottleshoptype const& bst = QMisc.bottle_shop_types[base_scr->catchall];
19688 //count and align the stuff
19689
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
4 for(int32_t i=0; i<3; ++i)
19690 {
19691
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(bst.fill[count] != 0)
19692 {
19693 3 ++count;
19694 3 }
19695 else
19696 {
19697 break;
19698 }
19699 3 }
19700
19701
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(count==1)
19702 {
19703 base = 88+32;
19704 }
19705
19706
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(count==2)
19707 {
19708 step = 6;
19709 }
19710
19711
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
4 for(int32_t i=0; i<count; i++)
19712 {
19713 6 adddummyitem(dx+(i<<step)+base, dy+89, /*Use item 0 as a dummy...*/0, ipHOLDUP+ipFADE+ipCHECK);
19714 //{ Setup dummy item
19715 3 item* curItem = ((item*)items.spr(items.Count()-1));
19716 3 curItem->PriceIndex = i;
19717 3 newcombo const& cmb = combobuf[bst.comb[i]];
19718
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(cmb.animflags & AF_EDITOR_ONLY)
19719 {
19720 curItem->yofs = -32768;
19721 }
19722 3 curItem->o_tile = cmb.o_tile;
19723 3 curItem->o_cset = bst.cset[i];
19724 3 curItem->cs = curItem->o_cset;
19725 3 curItem->tile = cmb.o_tile;
19726 3 curItem->o_speed = cmb.speed;
19727 3 curItem->o_delay = 0;
19728 3 curItem->frames = cmb.frames;
19729 3 curItem->flip = cmb.flip;
19730 3 curItem->type = itype_bottlefill; //no pickup w/o empty bottle
19731 3 curItem->pstring = 0;
19732 3 curItem->pickup = ipHOLDUP+ipFADE+ipCHECK;
19733 3 curItem->flash = false;
19734 3 curItem->twohand = false;
19735 3 curItem->anim = true;
19736 3 curItem->hit_width=1;
19737 3 curItem->hyofs=4;
19738 3 curItem->hit_height=12;
19739 3 curItem->script=0;
19740 3 curItem->txsz=1;
19741 3 curItem->tysz=1;
19742 //}
19743
19744 3 prices[i] = bst.price[i];
19745
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(prices[i]==0)
19746 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19747 3 int32_t itemid = current_item_id(itype_wealthmedal);
19748
19749
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(itemid>=0 && prices[i]!=100000)
19750 {
19751 if(itemsbuf[itemid].flags & item_flag1)
19752 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
19753 else
19754 prices[i]+=itemsbuf[itemid].misc1;
19755 prices[i]=vbound(prices[i], 0, 99999);
19756 if(prices[i]==0)
19757 prices[i]=100000;
19758 }
19759
19760
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if((bst.price[i])>1 && prices[i]<1)
19761 prices[i]=1;
19762 3 }
19763
19764 1 break;
19765 }
19766
19767 case rBOMBS: // more bombs
19768 38 additem(dx+120,dy+89,iRupy,ipDUMMY+ipMONEY);
19769 19 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19770 19 prices[0]=-base_scr->catchall;
19771 19 break;
19772
19773 case rARROWS: // more arrows
19774 additem(dx+120,dy+89,iRupy,ipDUMMY+ipMONEY);
19775 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19776 prices[0]=-base_scr->catchall;
19777 break;
19778
19779 case rSWINDLE: // leave heart container or money
19780 28 additem(dx+88,dy+89,iHeartC,ipDUMMY+ipMONEY);
19781 14 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19782 14 prices[0]=-1;
19783 28 additem(dx+152,dy+89,iRupy,ipDUMMY+ipMONEY);
19784 14 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19785 14 prices[1]=-base_scr->catchall;
19786 14 break;
19787
19788 }
19789
19790
3/4
✓ Branch 0 taken 1191 times.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1191 times.
1210 if(base_scr->room == rBOMBS || base_scr->room == rARROWS)
19791 {
19792 19 int32_t i = (base_scr->room == rSWINDLE ? 1 : 0);
19793 19 int32_t itemid = current_item_id(itype_wealthmedal);
19794
19795
1/2
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
19 if(itemid >= 0)
19796 {
19797 if(itemsbuf[itemid].flags & item_flag1)
19798 prices[i]*=(itemsbuf[itemid].misc1 /100.0);
19799 else
19800 prices[i]+=itemsbuf[itemid].misc1;
19801 }
19802
19803
2/4
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
19 if(base_scr->catchall>1 && prices[i]>-1)
19804 prices[i]=-1;
19805 19 }
19806
19807 1210 putprices(false);
19808
19809
2/2
✓ Branch 0 taken 1151 times.
✓ Branch 1 taken 59 times.
1210 if(str)
19810 {
19811 1151 donewmsg(base_scr, str);
19812 1151 }
19813 else
19814 {
19815 59 Hero.unfreeze();
19816 }
19817 1210 }
19818
19819 enum
19820 {
19821 MNU_CURSOR_TILE, MNU_CURSOR_CSET,
19822 MNU_CURSOR_WID, MNU_CURSOR_HEI, MNU_CURSOR_FLIP,
19823
19824 MNU_CHOSEN, MNU_TIMER, MNU_CAN_CONFIRM,
19825
19826 MNU_DATA_MAX
19827 };
19828 struct menu_choice
19829 {
19830 int32_t x, y;
19831 int32_t pos;
19832 int32_t upos, dpos, lpos, rpos;
19833 18 menu_choice() : x(0), y(0), pos(0), upos(0), dpos(0), lpos(0), rpos(0)
19834 18 {}
19835 18 menu_choice(int32_t x, int32_t y, int32_t pos, int32_t upos,
19836 int32_t dpos, int32_t lpos, int32_t rpos)
19837 18 : x(x), y(y), pos(pos), upos(upos), dpos(dpos), lpos(lpos), rpos(rpos)
19838 18 {}
19839 };
19840 static int32_t msg_menu_data[MNU_DATA_MAX];
19841 static bool do_run_menu = false;
19842 bool do_end_str = false;
19843 static bool wait_advance = false;
19844 414 static std::map<int32_t, menu_choice> menu_options;
19845 43871 void clr_msg_data()
19846 {
19847 43871 do_end_str = false;
19848 43871 wait_advance = false;
19849 43871 do_run_menu = false;
19850 43871 menu_options.clear();
19851 43871 memset(msg_menu_data, 0, sizeof(msg_menu_data));
19852 43871 }
19853
19854 static char namebuf[9] = {0};
19855 static char* nameptr = NULL;
19856 static int32_t ssc_tile_hei = -1, ssc_tile_hei_buf = -1;
19857 2036 bool runMenuCursor()
19858 {
19859 2036 clear_bitmap(msg_menu_bmp_buf);
19860
1/2
✓ Branch 0 taken 2036 times.
✗ Branch 1 not taken.
2036 if(!menu_options.size())
19861 {
19862 msg_menu_data[MNU_CHOSEN] = 0;
19863 return true; //end menu
19864 }
19865 2036 int32_t pos = msg_menu_data[MNU_CHOSEN];
19866 //If the cursor is at an invalid pos, find the first pos >= 0...
19867
1/2
✓ Branch 0 taken 2036 times.
✗ Branch 1 not taken.
2036 if(menu_options.find(pos) == menu_options.end())
19868 {
19869 pos = 0;
19870 while(menu_options.find(pos) == menu_options.end())
19871 ++pos;
19872 }
19873 2036 menu_choice* ch = &menu_options[pos];
19874
19875 2036 bool pressed = true;
19876
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2032 times.
2036 if(rUp()) pos = ch->upos;
19877
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2030 times.
2032 else if(rDown()) pos = ch->dpos;
19878
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2021 times.
2030 else if(rLeft()) pos = ch->lpos;
19879
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2010 times.
2021 else if(rRight()) pos = ch->rpos;
19880 2010 else pressed = false;
19881
19882
2/2
✓ Branch 0 taken 2010 times.
✓ Branch 1 taken 26 times.
2036 if(pressed)
19883 26 msg_menu_data[MNU_TIMER] = 1;
19884
19885 2036 bool hold_input = !((msg_menu_data[MNU_TIMER]++) % 20);
19886 2036 bool held = false;
19887
2/2
✓ Branch 0 taken 1946 times.
✓ Branch 1 taken 90 times.
2036 if(hold_input)
19888 {
19889 90 held = true;
19890
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 89 times.
90 if(Up()) pos = ch->upos;
19891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 else if(Down()) pos = ch->dpos;
19892
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 else if(Left()) pos = ch->lpos;
19893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 else if(Right()) pos = ch->rpos;
19894 89 else held = false;
19895 90 }
19896 //If the cursor is at an invalid pos, find the first pos >= 0...
19897
1/2
✓ Branch 0 taken 2036 times.
✗ Branch 1 not taken.
2036 if(menu_options.find(pos) == menu_options.end())
19898 {
19899 pos = 0;
19900 while(menu_options.find(pos) == menu_options.end())
19901 ++pos;
19902 }
19903
4/4
✓ Branch 0 taken 2010 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 2009 times.
✓ Branch 3 taken 27 times.
2036 if((pressed || held) && pos != msg_menu_data[MNU_CHOSEN])
19904 27 sfx(MsgStrings[msgstr].sfx);
19905
19906 2036 ch = &menu_options[pos];
19907 4072 overtileblock16(msg_menu_bmp_buf, msg_menu_data[MNU_CURSOR_TILE],
19908 2036 ch->x, ch->y, (int32_t)ceil(msg_menu_data[MNU_CURSOR_WID]/16.0),
19909 2036 (int32_t)ceil(msg_menu_data[MNU_CURSOR_HEI]/16.0),
19910 2036 msg_menu_data[MNU_CURSOR_CSET], msg_menu_data[MNU_CURSOR_FLIP]);
19911
19912 2036 msg_menu_data[MNU_CHOSEN] = pos;
19913
19914
2/2
✓ Branch 0 taken 1433 times.
✓ Branch 1 taken 603 times.
2036 if(!msg_menu_data[MNU_CAN_CONFIRM]) //Prevent instantly accepting when holding A
19915 {
19916 603 rAbtn(); //Eat
19917
2/2
✓ Branch 0 taken 598 times.
✓ Branch 1 taken 5 times.
603 if(!cAbtn()) msg_menu_data[MNU_CAN_CONFIRM] = 1;
19918 603 }
19919
19920
4/4
✓ Branch 0 taken 2010 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2009 times.
2036 bool ret = (pressed || held) ? false : rAbtn();
19921 //Eat inputs
19922 2036 rUp(); rDown(); rLeft(); rRight(); rAbtn();
19923
19924
2/2
✓ Branch 0 taken 2031 times.
✓ Branch 1 taken 5 times.
2036 if(ret)
19925 5 menu_options.clear();
19926
19927 2036 return ret;
19928 //false if pos changed this frame; no confirming while moving the cursor!
19929 2036 }
19930
19931 839994 bool bottom_margin_clip()
19932 {
19933 891831 return !get_qr(qr_OLD_STRING_EDITOR_MARGINS)
19934
2/2
✓ Branch 0 taken 788157 times.
✓ Branch 1 taken 51837 times.
839994 && cursor_y >= (msg_h + (get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)?16:0) - msg_margins[down]);
19935 }
19936
19937 void update_msgstr();
19938
19939 3293 static bool parsemsgcode(const StringCommand& command)
19940 {
19941 3293 auto& args = command.args;
19942 3293 int last_arg = 0;
19943
19944
18/38
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1280 times.
✓ Branch 3 taken 1644 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 56 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5 times.
✓ Branch 9 taken 7 times.
✓ Branch 10 taken 70 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 11 times.
✓ Branch 14 taken 22 times.
✓ Branch 15 taken 7 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 122 times.
✓ Branch 24 taken 28 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 5 times.
✓ Branch 29 taken 18 times.
✓ Branch 30 taken 5 times.
✓ Branch 31 taken 7 times.
✓ Branch 32 taken 3 times.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
3293 switch (command.code)
19945 {
19946 case MSGC_NEWLINE:
19947 {
19948 1280 ssc_tile_hei = ssc_tile_hei_buf;
19949
2/2
✓ Branch 0 taken 1278 times.
✓ Branch 1 taken 2 times.
1280 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
19950 1280 ssc_tile_hei_buf = -1;
19951 1280 cursor_y += thei + MsgStrings[msgstr].vspace;
19952 1280 cursor_x=msg_margins[left];
19953 1280 return true;
19954 }
19955
19956 case MSGC_COLOUR:
19957 {
19958 1644 int32_t cset = args[0];
19959 1644 msgcolour = CSET(cset)+(args[1]);
19960 1644 return true;
19961 }
19962
19963 case MSGC_SHDCOLOR:
19964 {
19965 int32_t cset = args[0];
19966 msg_shdcol = CSET(cset)+args[1];
19967 return true;
19968 }
19969 case MSGC_SHDTYPE:
19970 {
19971 msg_shdtype = args[0];
19972 return true;
19973 }
19974
19975 case MSGC_SPEED:
19976 {
19977 56 msgspeed=args[0];
19978 56 return true;
19979 }
19980
19981 case MSGC_CTRUP:
19982 {
19983 int32_t a1 = args[0];
19984 int32_t a2 = args[1];
19985 game->change_counter(a2, a1);
19986 return true;
19987 }
19988
19989 case MSGC_CTRDN:
19990 {
19991 5 int32_t a1 = args[0];
19992 5 int32_t a2 = args[1];
19993 5 game->change_counter(-a2, a1);
19994 5 return true;
19995 }
19996
19997 case MSGC_CTRSET:
19998 {
19999 7 int32_t a1 = args[0];
20000 7 int32_t a2 = args[1];
20001 7 game->set_counter(vbound(a2, 0, game->get_maxcounter(a1)), a1);
20002 7 return true;
20003 }
20004
20005 case MSGC_CTRUPPC:
20006 case MSGC_CTRDNPC:
20007 case MSGC_CTRSETPC:
20008 {
20009 2 int32_t counter = args[0];
20010 2 int32_t amount = args[1];
20011 2 amount = int32_t(vbound(amount*0.01, 0.0, 1.0)*game->get_maxcounter(counter));
20012
20013
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(command.code==MSGC_CTRDNPC)
20014 amount*=-1;
20015
20016
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(command.code==MSGC_CTRSETPC)
20017 game->set_counter(amount, counter);
20018 else
20019 2 game->change_counter(amount, counter);
20020
20021 2 return true;
20022 }
20023
20024 case MSGC_GIVEITEM:
20025 {
20026 70 int32_t itemID = args[0];
20027
20028 70 getitem(itemID, true);
20029
2/4
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 70 times.
70 if ( !FFCore.doscript(ScriptType::Item, itemID) && (((unsigned)itemID) < 256) )
20030 {
20031 70 FFCore.reset_script_engine_data(ScriptType::Item, itemID);
20032 70 FFCore.doscript(ScriptType::Item, itemID) = (itemsbuf[itemID].flags&item_passive_script) > 0;
20033 70 }
20034 70 return true;
20035 }
20036
20037
20038 case MSGC_WARP:
20039 {
20040 int32_t dmap = args[0];
20041 int32_t scrn = args[1];
20042 int32_t dx = args[2];
20043 int32_t dy = args[3];
20044 int32_t wfx = args[4];
20045 int32_t sfx = args[5];
20046 if(dx >= MAX_SCC_ARG) dx = -1;
20047 if(dy >= MAX_SCC_ARG) dy = -1;
20048 FFCore.warp_player(wtIWARP, dmap, scrn, dx, dy, wfx, sfx, 0, 0);
20049 do_end_str = true;
20050 return true;
20051 }
20052
20053 case MSGC_SETSCREEND:
20054 {
20055 int32_t dmap = (args[0]<<7); //dmap and screen may be transposed here.
20056 int32_t screen = args[1];
20057 int32_t reg = args[2];
20058 int32_t val = args[3];
20059 FFCore.set_screen_d(screen + dmap, reg, val);
20060 return true;
20061 }
20062 case MSGC_TAKEITEM:
20063 {
20064 11 int32_t itemID = args[0];
20065
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if ( FFCore.doscript(ScriptType::Item, itemID) )
20066 {
20067 FFCore.doscript(ScriptType::Item, itemID) = 4; //Val of 4 means 'clear stack and quit'
20068 }
20069 11 takeitem(itemID);
20070
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_bwpn == itemID )
20071 {
20072 game->forced_bwpn = -1;
20073 } //not else if! -Z
20074
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_awpn == itemID )
20075 {
20076 game->forced_awpn = -1;
20077 }
20078
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_xwpn == itemID )
20079 {
20080 game->forced_xwpn = -1;
20081 } //not else if! -Z
20082
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_ywpn == itemID )
20083 {
20084 game->forced_ywpn = -1;
20085 }
20086 11 verifyBothWeapons();
20087 11 return true;
20088 }
20089
20090 case MSGC_SFX:
20091 {
20092 22 sfx(args[0]);
20093 22 return true;
20094 }
20095
20096 case MSGC_MIDI:
20097 {
20098 7 int32_t music = args[0];
20099
20100
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1 times.
7 if(music==0)
20101 1 music_stop();
20102 else
20103 6 jukebox(music+(ZC_MIDI_COUNT-1));
20104
20105 7 return true;
20106 }
20107
20108 case MSGC_FONT:
20109 {
20110 int fontid = args[0];
20111 int oh = text_height(msgfont);
20112 msgfont = get_zc_font(fontid);
20113 int nh = text_height(msgfont);
20114 int mh = std::max(oh,nh);
20115 if(mh > ssc_tile_hei_buf)
20116 ssc_tile_hei_buf = mh;
20117 return true;
20118 }
20119 case MSGC_RUN_FRZ_GENSCR:
20120 {
20121 word scr_id = args[0];
20122 bool force_redraw = args[1]!=0;
20123 if(force_redraw)
20124 {
20125 update_msgstr();
20126 draw_screen();
20127 }
20128 FFCore.runGenericFrozenEngine(scr_id);
20129 return true;
20130 }
20131 case MSGC_DRAWTILE:
20132 {
20133 int32_t tl = args[0];
20134 int32_t cs = args[1];
20135 int32_t t_wid = args[2];
20136 int32_t t_hei = args[3];
20137 int32_t fl = args[4];
20138
20139 if(cursor_x+MsgStrings[msgstr].hspace + t_wid > msg_w-msg_margins[right])
20140 {
20141 ssc_tile_hei = ssc_tile_hei_buf;
20142 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20143 ssc_tile_hei_buf = -1;
20144 cursor_y += thei + MsgStrings[msgstr].vspace;
20145 if(bottom_margin_clip()) return true;
20146 cursor_x=msg_margins[left];
20147 }
20148
20149 overtileblock16(msg_txt_bmp_buf, tl, cursor_x, cursor_y, (int32_t)ceil(t_wid/16.0), (int32_t)ceil(t_hei/16.0), cs, fl);
20150 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, t_hei);
20151 cursor_x += MsgStrings[msgstr].hspace + t_wid;
20152 return true;
20153 }
20154
20155 case MSGC_GOTOIFRAND:
20156 {
20157 1 int32_t odds = args[0];
20158
20159 1 last_arg = 1;
20160
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!odds || !(zc_oldrand()%odds))
20161 1 goto switched;
20162
20163 return true;
20164 }
20165
20166 case MSGC_GOTOIFGLOBAL:
20167 {
20168 int32_t arg = args[0];
20169 int32_t d = zc_min(7,arg);
20170 int32_t s = ((get_currdmap())<<7) + get_currscr()-(DMaps[get_currdmap()].type==dmOVERW ? 0 : DMaps[get_currdmap()].xoff);
20171 arg = args[1];
20172
20173 if(game->screen_d[s][d] >= arg)
20174 {
20175 last_arg = 2;
20176 goto switched;
20177 }
20178
20179 return true;
20180 }
20181
20182 case MSGC_CHANGEPORTRAIT:
20183 {
20184 return true; //not implemented
20185 }
20186
20187 case MSGC_GOTOIFCREEND:
20188 {
20189 int32_t dmap = (args[0]<<7); //dmap and screen may be transposed here.
20190 int32_t screen = args[1];
20191 int32_t reg = args[2];
20192 int32_t val = args[3];
20193 if ( FFCore.get_screen_d(screen + dmap, reg) >= val )
20194 {
20195 last_arg = 4;
20196 goto switched;
20197 }
20198 return true;
20199 }
20200
20201 case MSGC_GOTOIF:
20202 {
20203 122 int32_t it = args[0];
20204
20205
3/4
✓ Branch 0 taken 122 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 87 times.
✓ Branch 3 taken 35 times.
122 if(unsigned(it)<MAXITEMS && game->item[it])
20206 {
20207 35 last_arg = 1;
20208 35 goto switched;
20209 }
20210
20211 87 return true;
20212 }
20213
20214 case MSGC_GOTOIFCTR:
20215 {
20216
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14 times.
28 if(game->get_counter(args[0]) >= args[1])
20217 {
20218 14 last_arg = 2;
20219 14 goto switched;
20220 }
20221
20222 14 return true;
20223 }
20224
20225 case MSGC_GOTOIFCTRPC:
20226 {
20227 int32_t counter = args[0];
20228 int32_t amount = (int32_t)((args[1]/100)*game->get_maxcounter(counter));
20229
20230 if(game->get_counter(counter)>=amount)
20231 {
20232 last_arg = 2;
20233 goto switched;
20234 }
20235
20236 return true;
20237 }
20238
20239 case MSGC_GOTOIFTRICOUNT:
20240 {
20241 if(TriforceCount() >= args[0])
20242 {
20243 last_arg = 1;
20244 goto switched;
20245 }
20246
20247 return true;
20248 }
20249
20250 case MSGC_GOTOIFTRI:
20251 {
20252 int32_t lev = args[0];
20253
20254 if(lev<MAXLEVELS && game->lvlitems[lev]&(1 << li_mcguffin))
20255 {
20256 last_arg = 1;
20257 goto switched;
20258 }
20259
20260 return true;
20261 }
20262
20263 case MSGC_SETUPMENU:
20264 {
20265 5 msg_menu_data[MNU_CURSOR_TILE] = args[0];
20266 5 msg_menu_data[MNU_CURSOR_CSET] = args[1];
20267 5 msg_menu_data[MNU_CURSOR_WID] = args[2];
20268 5 msg_menu_data[MNU_CURSOR_HEI] = args[3];
20269 5 msg_menu_data[MNU_CURSOR_FLIP] = args[4];
20270 5 return true;
20271 }
20272
20273 case MSGC_MENUCHOICE:
20274 {
20275 18 int32_t pos = args[0];
20276 18 int32_t upos = args[1];
20277 18 int32_t dpos = args[2];
20278 18 int32_t lpos = args[3];
20279 18 int32_t rpos = args[4];
20280
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 2 times.
18 if(cursor_x+MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID] > msg_w-msg_margins[right])
20281 {
20282 2 ssc_tile_hei = ssc_tile_hei_buf;
20283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20284 2 ssc_tile_hei_buf = -1;
20285 2 cursor_y += thei + MsgStrings[msgstr].vspace;
20286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(bottom_margin_clip()) break;
20287 2 cursor_x=msg_margins[left];
20288 2 }
20289
20290 36 menu_options[pos] = menu_choice(cursor_x, cursor_y, pos,
20291 18 upos, dpos, lpos, rpos);
20292
20293
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
18 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, msg_menu_data[MNU_CURSOR_HEI]);
20294 18 cursor_x += MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID];
20295 18 return true;
20296 }
20297
20298 case MSGC_RUNMENU:
20299 {
20300 5 msg_menu_data[MNU_CHOSEN] = 0;
20301 5 msg_menu_data[MNU_CAN_CONFIRM] = 0;
20302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(menu_options.size() < 1)
20303 return true;
20304 5 do_run_menu = true;
20305 5 return true;
20306 }
20307
20308 case MSGC_GOTOMENUCHOICE:
20309 {
20310 7 int32_t choice = args[0];
20311
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
7 if(msg_menu_data[MNU_CHOSEN] == choice)
20312 {
20313 5 last_arg = 1;
20314 5 goto switched;
20315 }
20316
20317 2 return true;
20318 }
20319
20320 case MSGC_ENDSTRING:
20321 {
20322 3 do_end_str = true;
20323 3 return true;
20324 }
20325 case MSGC_WAIT_ADVANCE:
20326 {
20327 wait_advance = true;
20328 linkedmsgclk = 51;
20329 return true;
20330 }
20331 case MSGC_TRIGSECRETS:
20332 {
20333 bool perm = args[0];
20334 trigger_secrets_for_screen(TriggerSource::SCC, msgscr, false);
20335 if(perm)
20336 setmapflag(msgscr, mSECRET);
20337 return true;
20338 }
20339 case MSGC_TRIG_CMB_COPYCAT:
20340 {
20341 int copy_id = args[0];
20342 if(copy_id == byte(copy_id))
20343 trig_copycat(copy_id);
20344 return true;
20345 }
20346 case MSGC_SETSCREENSTATE:
20347 {
20348 int32_t flag = args[0];
20349 if(unsigned(flag)>=mMAXIND)
20350 {
20351 Z_error("SCC 133: Flag %d is invalid\n", flag);
20352 return true;
20353 }
20354 bool state = args[1];
20355 if(state)
20356 setmapflag(msgscr, 1<<flag);
20357 else
20358 unsetmapflag(msgscr, 1<<flag, true);
20359 return true;
20360 }
20361 case MSGC_SETSCREENSTATER:
20362 {
20363 int32_t map = args[0];
20364 int32_t scrid = args[1];
20365 if(map < 1 || map > map_count)
20366 {
20367 Z_error("SCC 134: Map %d is invalid\n", map);
20368 return true;
20369 }
20370 if(unsigned(scrid)>=0x80)
20371 {
20372 Z_error("SCC 134: Screen %d is invalid\n", scrid);
20373 return true;
20374 }
20375
20376 int32_t flag = args[2];
20377 if(unsigned(flag)>=mMAXIND)
20378 {
20379 Z_error("SCC 134: Flag %d is invalid\n", flag);
20380 return true;
20381 }
20382 bool state = args[3];
20383 if(state)
20384 setmapflag_mi(msgscr, mapind(map,scrid),1<<flag);
20385 else
20386 unsetmapflag_mi(msgscr, mapind(map,scrid),1<<flag,true);
20387 return true;
20388 }
20389 switched:
20390 55 int32_t lev = args[last_arg];
20391
3/4
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
55 if(lev && get_qr(qr_SCC_GOTO_RESPECTS_CONTFLAG)
20392
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 33 times.
54 && (MsgStrings[lev].stringflags & STRINGFLAG_CONT))
20393 {
20394 setmsg(lev);
20395 }
20396 else
20397 {
20398 55 donewmsg(msgscr, lev);
20399 55 ssc_tile_hei_buf = -1;
20400 }
20401 55 putprices(false);
20402 55 return true;
20403 }
20404
20405 return false;
20406 3293 }
20407
20408 3299 static std::string parsemsgcode2(const StringCommand& command)
20409 {
20410
2/2
✓ Branch 0 taken 3293 times.
✓ Branch 1 taken 6 times.
3299 if (command.code == MSGC_NAME)
20411 {
20412
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 return game->get_name();
20413 }
20414 else
20415 {
20416 3293 parsemsgcode(command);
20417 }
20418
20419
1/2
✓ Branch 0 taken 3293 times.
✗ Branch 1 not taken.
3293 return "";
20420 3299 }
20421
20422 252704 static bool putmsgchar(bool play_sfx)
20423 {
20424 DCHECK(msg_it->state == MsgStr::iterator::CHARACTER);
20425 DCHECK(!msg_it->character.empty());
20426
20427
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252704 times.
252704 if (bottom_margin_clip())
20428 return false;
20429
20430 // If the current word would overflow the margins, increment cursor to the next line.
20431 252704 const char* rem_word = msg_it->remaining_word();
20432 252704 int tlength = text_length(msgfont, rem_word) + ((int32_t)strlen(rem_word)*MsgStrings[msgstr].hspace);
20433
4/4
✓ Branch 0 taken 5671 times.
✓ Branch 1 taken 247033 times.
✓ Branch 2 taken 498 times.
✓ Branch 3 taken 5081 times.
258283 if (cursor_x+tlength > (msg_w-msg_margins[right]) &&
20434
4/4
✓ Branch 0 taken 5579 times.
✓ Branch 1 taken 92 times.
✓ Branch 2 taken 5081 times.
✓ Branch 3 taken 92 times.
5671 ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)) ? true : strcmp(rem_word," ")!=0))
20435 {
20436 5579 ssc_tile_hei = ssc_tile_hei_buf;
20437
1/2
✓ Branch 0 taken 5579 times.
✗ Branch 1 not taken.
5579 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20438 5579 ssc_tile_hei_buf = -1;
20439 5579 cursor_y += thei + MsgStrings[msgstr].vspace;
20440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5579 times.
5579 if (bottom_margin_clip()) return false;
20441
20442 5579 cursor_x = msg_margins[left];
20443 5579 }
20444
20445
2/2
✓ Branch 0 taken 34959 times.
✓ Branch 1 taken 217745 times.
252704 if (play_sfx)
20446 217745 sfx(MsgStrings[msgstr].sfx);
20447
20448 // Print the character (unless it's just a space).
20449
2/2
✓ Branch 0 taken 59004 times.
✓ Branch 1 taken 193700 times.
252704 if (msg_it->character != " ")
20450 193700 textout_styled_aligned_ex(msg_txt_bmp_buf, msgfont, msg_it->character.c_str(), cursor_x, cursor_y, msg_shdtype, sstaLEFT, msgcolour, msg_shdcol, -1);
20451
20452 // Move the cursor.
20453 252704 cursor_x += msgfont->vtable->text_length(msgfont, msg_it->character.c_str());
20454
2/2
✓ Branch 0 taken 59004 times.
✓ Branch 1 taken 193700 times.
252704 if (msg_it->character != " ")
20455 193700 cursor_x += MsgStrings[msgstr].hspace;
20456
20457 252704 return true;
20458 252704 }
20459
20460 enum msg_tick_result {msg_tick_exit, msg_tick_break, msg_tick_continue};
20461
20462 static void msg_tick_end(bool disappear = false);
20463 241762 static msg_tick_result msg_tick(bool play_sfx, bool burst_mode)
20464 {
20465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 241762 times.
241762 if (msg_it->done())
20466 return msg_tick_exit;
20467
20468
2/2
✓ Branch 0 taken 2031 times.
✓ Branch 1 taken 239731 times.
241762 if (!do_run_menu)
20469 {
20470
4/4
✓ Branch 0 taken 239731 times.
✓ Branch 1 taken 3299 times.
✓ Branch 2 taken 239731 times.
✓ Branch 3 taken 3299 times.
243030 while (msg_it->state == MsgStr::iterator::COMMAND && !do_run_menu)
20471 {
20472 3299 bool one_frame_command_delay = !replay_version_check(41);
20473 3299 std::string text = parsemsgcode2(msg_it->command);
20474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3299 times.
3299 if (wait_advance)
20475 break;
20476
20477
2/2
✓ Branch 0 taken 3293 times.
✓ Branch 1 taken 6 times.
3299 if (text.empty())
20478 {
20479
2/4
✓ Branch 0 taken 3293 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3293 times.
✗ Branch 3 not taken.
3293 msg_it->set_buffer("");
20480 // Advance the iterator to run many commands in one frame.
20481
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 3169 times.
3293 if (!one_frame_command_delay)
20482
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 msg_it->next();
20483 3293 }
20484 else
20485 {
20486
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 msg_it->set_buffer(text);
20487
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 msg_it->next();
20488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (one_frame_command_delay)
20489 6 msg_it->post_segment_delay = 1;
20490 }
20491
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 3299 times.
3299 }
20492
20493
2/2
✓ Branch 0 taken 3177 times.
✓ Branch 1 taken 236554 times.
239731 if (msg_it->state == MsgStr::iterator::CHARACTER)
20494 {
20495
1/2
✓ Branch 0 taken 236554 times.
✗ Branch 1 not taken.
236554 if (!putmsgchar(play_sfx)) return msg_tick_break;
20496 236554 }
20497 239731 }
20498
20499 241762 bool wait_advance_check_early = !burst_mode;
20500
20501
2/2
✓ Branch 0 taken 78489 times.
✓ Branch 1 taken 163273 times.
241762 if (wait_advance_check_early)
20502 {
20503
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 163272 times.
163273 if (do_end_str)
20504 {
20505 1 msg_tick_end();
20506 1 return msg_tick_exit;
20507 }
20508
20509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 163272 times.
163272 if (wait_advance)
20510 {
20511 msg_it->next();
20512 return msg_tick_exit;
20513 }
20514 163272 }
20515
20516
2/2
✓ Branch 0 taken 239725 times.
✓ Branch 1 taken 2036 times.
241761 if (do_run_menu)
20517 {
20518
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2031 times.
2036 if (runMenuCursor())
20519 {
20520 5 do_run_menu = false;
20521
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 if (!burst_mode)
20522 {
20523 2 msg_it->next();
20524 2 return msg_tick(play_sfx, burst_mode);
20525 }
20526 3 }
20527 2031 else return msg_tick_break;
20528 3 }
20529
20530 239728 msg_it->next();
20531
20532
2/2
✓ Branch 0 taken 161773 times.
✓ Branch 1 taken 77955 times.
239728 if (!wait_advance_check_early)
20533 {
20534
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 77953 times.
77955 if (do_end_str)
20535 {
20536 2 msg_tick_end();
20537 2 return msg_tick_exit;
20538 }
20539
20540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77953 times.
77953 if (wait_advance)
20541 return msg_tick_exit;
20542 77953 }
20543
20544
4/4
✓ Branch 0 taken 4007 times.
✓ Branch 1 taken 235719 times.
✓ Branch 2 taken 2017 times.
✓ Branch 3 taken 1990 times.
239726 if (msg_it->done() && MsgStrings[msgstr].nextstring)
20545 {
20546
1/2
✓ Branch 0 taken 2017 times.
✗ Branch 1 not taken.
2017 if (MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
20547 setmsg(MsgStrings[msgstr].nextstring);
20548 2017 }
20549
20550 239726 return msg_tick_continue;
20551 241762 }
20552
20553 165560 static void msg_tick_end(bool disappear)
20554 {
20555
2/2
✓ Branch 0 taken 164547 times.
✓ Branch 1 taken 1013 times.
165560 if (disappear)
20556 1013 goto disappear;
20557
20558 // Done printing the string
20559
8/8
✓ Branch 0 taken 164544 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 163047 times.
✓ Branch 3 taken 1497 times.
✓ Branch 4 taken 159021 times.
✓ Branch 5 taken 4026 times.
✓ Branch 6 taken 159021 times.
✓ Branch 7 taken 4026 times.
164547 if (do_end_str || !do_run_menu && (msg_it->done() || bottom_margin_clip()) && !linkedmsgclk)
20560 {
20561
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 4026 times.
4029 if(!do_end_str)
20562 {
20563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4026 times.
4026 while (msg_it->state == MsgStr::iterator::COMMAND)
20564 {
20565 parsemsgcode2(msg_it->command);
20566 msg_it->next();
20567 }
20568 4026 }
20569
20570 // Go to next string, or make it disappear by going to string 0.
20571
5/6
✓ Branch 0 taken 2010 times.
✓ Branch 1 taken 2019 times.
✓ Branch 2 taken 996 times.
✓ Branch 3 taken 1014 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 996 times.
4029 if(MsgStrings[msgstr].nextstring!=0 || get_qr(qr_MSGDISAPPEAR) || enqueued_str)
20572 {
20573 3033 linkedmsgclk=do_end_str?1:51;
20574 3033 }
20575
20576
2/2
✓ Branch 0 taken 2010 times.
✓ Branch 1 taken 2019 times.
4029 if(MsgStrings[msgstr].nextstring==0)
20577 {
20578
2/2
✓ Branch 0 taken 1014 times.
✓ Branch 1 taken 996 times.
2010 if(!get_qr(qr_MSGDISAPPEAR))
20579 996 {
20580 disappear:
20581 2009 msg_active = false;
20582 2009 Hero.finishedmsg();
20583 2009 }
20584
20585
2/2
✓ Branch 0 taken 3010 times.
✓ Branch 1 taken 13 times.
3023 if(repaircharge)
20586 {
20587
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 game->change_drupy(-(cur_screen >= 128 ? special_warp_return_scr : msgscr)->catchall);
20588 13 repaircharge = 0;
20589 13 }
20590
20591
2/2
✓ Branch 0 taken 3021 times.
✓ Branch 1 taken 2 times.
3023 if(adjustmagic)
20592 {
20593
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(get_qr(qr_OLD_HALF_MAGIC))
20594 {
20595
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(game->get_magicdrainrate())
20596 2 game->set_magicdrainrate(1);
20597 2 }
20598 else if(game->get_magicdrainrate() > 1)
20599 {
20600 game->set_magicdrainrate(game->get_magicdrainrate()/2);
20601 }
20602 2 adjustmagic = false;
20603 2 sfx(WAV_SCALE);
20604
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 setmapflag(msgscr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
20605 2 }
20606
20607
2/2
✓ Branch 0 taken 3021 times.
✓ Branch 1 taken 2 times.
3023 if(learnslash)
20608 {
20609 2 game->set_canslash(1);
20610 2 learnslash = false;
20611 2 sfx(WAV_SCALE);
20612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 setmapflag(msgscr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
20613 2 }
20614 3023 }
20615 5042 }
20616 165560 }
20617
20618 6228 static void msg_consume_spaces()
20619 {
20620
2/2
✓ Branch 0 taken 6228 times.
✓ Branch 1 taken 16150 times.
22378 while (msg_it->character == " ")
20621 {
20622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16150 times.
16150 if (!putmsgchar(false)) break;
20623
20624 // Advance the iterator.
20625 16150 msg_it->next();
20626
20627 // The "Continue From Previous" feature
20628
1/2
✓ Branch 0 taken 16150 times.
✗ Branch 1 not taken.
16150 if (msg_it->state == MsgStr::iterator::DONE)
20629 {
20630 if(MsgStrings[msgstr].nextstring)
20631 {
20632 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
20633 {
20634 setmsg(MsgStrings[msgstr].nextstring);
20635 }
20636 }
20637 }
20638 }
20639 6228 }
20640
20641 14618334 void putmsg()
20642 {
20643
2/2
✓ Branch 0 taken 681711 times.
✓ Branch 1 taken 13936623 times.
14618334 if(!msgorig) msgorig=msgstr;
20644
20645
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14618334 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14618334 if(wait_advance && linkedmsgclk < 1)
20646 linkedmsgclk = 1;
20647
2/2
✓ Branch 0 taken 14340154 times.
✓ Branch 1 taken 278180 times.
14618334 if(linkedmsgclk>0)
20648 {
20649
2/2
✓ Branch 0 taken 126729 times.
✓ Branch 1 taken 151451 times.
278180 if(linkedmsgclk==1)
20650 {
20651
6/6
✓ Branch 0 taken 126726 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 123816 times.
✓ Branch 3 taken 2910 times.
✓ Branch 4 taken 118 times.
✓ Branch 5 taken 123698 times.
126729 if(do_end_str||cAbtn()||cBbtn())
20652 {
20653 3031 do_end_str = false;
20654 3031 linkedmsgclk = 0;
20655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3031 times.
3031 if(wait_advance)
20656 {
20657 wait_advance = false;
20658 }
20659 else
20660 {
20661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3031 times.
3031 if (!msgscr) msgscr = hero_scr;
20662 3031 msgstr=MsgStrings[msgstr].nextstring;
20663 3031 ssc_tile_hei_buf = -1;
20664
3/4
✓ Branch 0 taken 1013 times.
✓ Branch 1 taken 2018 times.
✓ Branch 2 taken 1013 times.
✗ Branch 3 not taken.
3031 if(!msgstr && enqueued_str)
20665 {
20666 msgstr = enqueued_str;
20667 enqueued_str = 0;
20668 }
20669
2/2
✓ Branch 0 taken 1013 times.
✓ Branch 1 taken 2018 times.
3031 if(!msgstr)
20670 {
20671 1013 msgfont=get_zc_font(font_zfont);
20672
20673
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1009 times.
1013 if(msgscr->room!=rGRUMBLE)
20674 1009 blockpath=false;
20675
20676 1013 dismissmsg();
20677 1013 msg_tick_end(true);
20678 1013 return;
20679 }
20680
20681 2018 donewmsg(msgscr, msgstr);
20682 2018 putprices(false);
20683 }
20684 2018 }
20685 125716 }
20686 else
20687 {
20688 151451 --linkedmsgclk;
20689 }
20690 277167 }
20691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14617321 times.
14617321 if(wait_advance) return; //Waiting for buttonpress
20692
20693
9/10
✓ Branch 0 taken 14615366 times.
✓ Branch 1 taken 1955 times.
✓ Branch 2 taken 676780 times.
✓ Branch 3 taken 13938586 times.
✓ Branch 4 taken 263442 times.
✓ Branch 5 taken 413338 times.
✓ Branch 6 taken 259417 times.
✓ Branch 7 taken 4025 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 259417 times.
14617321 if(!do_run_menu && (!msgstr || !msg_it || msg_it->done() || bottom_margin_clip()))
20694 {
20695
2/2
✓ Branch 0 taken 13938586 times.
✓ Branch 1 taken 417363 times.
14355949 if(!msgstr)
20696 13938586 msgorig=0;
20697
20698 14355949 msg_active = false;
20699 14355949 msg_it.reset();
20700 14355949 return;
20701 }
20702
20703
1/2
✓ Branch 0 taken 261372 times.
✗ Branch 1 not taken.
261372 if (!msg_it)
20704 return;
20705
20706 261372 msg_onscreen = true; // Now the message is onscreen (see donewmsg()).
20707
20708
2/2
✓ Branch 0 taken 257323 times.
✓ Branch 1 taken 4049 times.
261372 if (msg_it->state == MsgStr::iterator::NOT_STARTED)
20709 {
20710 4049 msg_it->next();
20711 4049 msg_consume_spaces();
20712 4049 }
20713
20714 // If the player is holding down the B button, or if msgspeed is 0, process as many characters
20715 // as possible. This skips the character-by-character animation that usually renders a string
20716 // slowly over many frames.
20717
4/4
✓ Branch 0 taken 1381 times.
✓ Branch 1 taken 259991 times.
✓ Branch 2 taken 897 times.
✓ Branch 3 taken 259094 times.
261372 if ((cBbtn() && get_qr(qr_ALLOWMSGBYPASS)) || msgspeed == 0)
20718 {
20719
2/2
✓ Branch 0 taken 1274 times.
✓ Branch 1 taken 78499 times.
80231 while (!msg_it->done())
20720 {
20721
5/6
✓ Branch 0 taken 20654 times.
✓ Branch 1 taken 57845 times.
✓ Branch 2 taken 20644 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 20644 times.
✗ Branch 5 not taken.
78499 if (msgspeed && !(cBbtn() && get_qr(qr_ALLOWMSGBYPASS)))
20722 10 goto breakout; // break out if message speed was changed to non-zero
20723
20724 78489 auto tick = msg_tick(msg_it->character != " ", true);
20725
2/2
✓ Branch 0 taken 77955 times.
✓ Branch 1 taken 534 times.
78489 if (tick == msg_tick_break)
20726 534 break;
20727
2/2
✓ Branch 0 taken 77953 times.
✓ Branch 1 taken 2 times.
77955 if (tick == msg_tick_exit)
20728 2 return;
20729 }
20730
20731
2/2
✓ Branch 0 taken 534 times.
✓ Branch 1 taken 1274 times.
1808 if (!do_run_menu)
20732 {
20733 1274 msgclk = 72;
20734 1274 }
20735 1808 }
20736 else
20737 259094 {
20738 breakout:
20739 259104 word tempspeed = msgspeed;
20740
2/2
✓ Branch 0 taken 258141 times.
✓ Branch 1 taken 963 times.
259104 if (do_run_menu)
20741 963 tempspeed = 0;
20742
6/6
✓ Branch 0 taken 207843 times.
✓ Branch 1 taken 51261 times.
✓ Branch 2 taken 121553 times.
✓ Branch 3 taken 86290 times.
✓ Branch 4 taken 111476 times.
✓ Branch 5 taken 10077 times.
259104 if(((msgclk++)%(tempspeed+1)<tempspeed)&&((!cAbtn())||(!get_qr(qr_ALLOWFASTMSG))))
20743 96367 return;
20744 }
20745
20746 // Process the next msg tick.
20747 // This will either print a single character, or process a single string command (with one
20748 // exception).
20749
3/4
✓ Branch 0 taken 163271 times.
✓ Branch 1 taken 1274 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 163271 times.
164545 if (!msg_it->done() && !bottom_margin_clip())
20750 {
20751 // This may run an additional tick in the case of a string menu finishing: the first
20752 // tick wraps up the menu, and then a second tick processes the next character or command.
20753 163271 auto tick = msg_tick(true, false);
20754
2/2
✓ Branch 0 taken 1497 times.
✓ Branch 1 taken 161774 times.
163271 if (tick == msg_tick_break)
20755 {
20756 1497 msg_tick_end();
20757 1497 return;
20758 }
20759
2/2
✓ Branch 0 taken 161773 times.
✓ Branch 1 taken 1 times.
161774 if (tick == msg_tick_exit)
20760 1 return;
20761
20762 // If the next two characters are spaces, consume all upcoming spaces now.
20763
13/20
✓ Branch 0 taken 2752 times.
✓ Branch 1 taken 159021 times.
✓ Branch 2 taken 159021 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26249 times.
✓ Branch 5 taken 132772 times.
✓ Branch 6 taken 26249 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 26249 times.
✓ Branch 10 taken 135524 times.
✓ Branch 11 taken 26249 times.
✓ Branch 12 taken 2752 times.
✓ Branch 13 taken 159021 times.
✓ Branch 14 taken 159594 times.
✓ Branch 15 taken 2179 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
188022 if (!msg_it->done() && msg_it->peek(0) == " " && msg_it->peek(1) == " ")
20764 2179 msg_consume_spaces();
20765 161773 }
20766
20767 163047 msg_tick_end();
20768 14617876 }
20769
20770 124732 int32_t message_more_y()
20771 {
20772 //Is the flag ticked, do we really want a message more y larger than 160?
20773
5/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 124704 times.
✓ Branch 2 taken 124732 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 124704 times.
✓ Branch 5 taken 28 times.
124732 int32_t msgy=zc_min((zinit.msg_more_is_offset==0)?zinit.msg_more_y:zinit.msg_more_y+MsgStrings[msgstr].y ,160);
20774 124732 msgy+=playing_field_offset;
20775 124732 return msgy;
20776 }
20777
20778 /*** Collision detection & handling ***/
20779
20780 14306378 void clear_script_one_frame_conditions()
20781 {
20782
2/2
✓ Branch 0 taken 38991403 times.
✓ Branch 1 taken 14306378 times.
53297781 for(int32_t j=0; j<guys.Count(); j++)
20783 {
20784 38991403 enemy *e = (enemy*)guys.spr(j);
20785
2/2
✓ Branch 0 taken 662853851 times.
✓ Branch 1 taken 38991403 times.
701845254 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) e->hitby[q] = 0;
20786 38991403 }
20787 14306378 }
20788
20789 4883715 void check_enemy_lweapon_collision(weapon *w)
20790 {
20791
8/8
✓ Branch 0 taken 4267271 times.
✓ Branch 1 taken 616444 times.
✓ Branch 2 taken 3271483 times.
✓ Branch 3 taken 995788 times.
✓ Branch 4 taken 3209341 times.
✓ Branch 5 taken 62142 times.
✓ Branch 6 taken 16738 times.
✓ Branch 7 taken 3192603 times.
4883715 if(!(w->Dead()) && w->id!=wSword && w->id!=wHammer && w->id!=wWand)
20792 {
20793
2/2
✓ Branch 0 taken 3176788 times.
✓ Branch 1 taken 11214738 times.
14391526 for(int32_t j=0; j<guys.Count(); j++)
20794 {
20795 11214738 enemy *e = (enemy*)guys.spr(j);
20796
20797 11214738 bool didhit = e->hit(w);
20798 //boomerangs and such that last for more than a frame can write hitby[] for more than one frame,
20799 //because this only checks `if(dying || clk<0 || hclk>0 || superman)`
20800
2/2
✓ Branch 0 taken 10993873 times.
✓ Branch 1 taken 220865 times.
11214738 if(didhit)
20801 {
20802 // !(e->stunclk)
20803 220865 int32_t h = e->takehit(w);
20804
2/2
✓ Branch 0 taken 186989 times.
✓ Branch 1 taken 33876 times.
220865 if (h < 0) // hitby code
20805 {
20806 33876 int indx = Lwpns.find(w);
20807
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33876 times.
33876 if(indx > -1)
20808 33876 e->hitby[HIT_BY_LWEAPON] = indx+1;
20809 33876 e->hitby[HIT_BY_LWEAPON_UID] = w->getUID();
20810 33876 e->hitby[HIT_BY_LWEAPON_TYPE] = w->id;
20811
2/2
✓ Branch 0 taken 31471 times.
✓ Branch 1 taken 2405 times.
33876 if (w->parentitem > -1) e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = itemsbuf[w->parentitem].type;
20812 2405 else e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = -1;
20813 33876 e->hitby[HIT_BY_LWEAPON_PARENT_ID] = w->parentitem;
20814 33876 e->hitby[HIT_BY_LWEAPON_ENGINE_UID] = w->getUID();
20815 //we may need to handle this in special cases. -Z
20816 // arrow item pierce flag, for example -Em
20817 33876 }
20818
20819
2/2
✓ Branch 0 taken 33876 times.
✓ Branch 1 taken 186989 times.
220865 if(h < 0) // hit, check if weapon is "out of pierces"
20820 33876 w->hit_pierce(e, h);
20821
2/2
✓ Branch 0 taken 176579 times.
✓ Branch 1 taken 10410 times.
186989 else if(h > 0) // blocked
20822 10410 w->onhit(false, e, h);
20823
2/2
✓ Branch 0 taken 218191 times.
✓ Branch 1 taken 2674 times.
220865 if(abs(h) == 2)
20824 2674 break; // some enemy classes force a weapon hitting them to "wait a frame"
20825 218191 }
20826
20827
2/2
✓ Branch 0 taken 11198923 times.
✓ Branch 1 taken 13141 times.
11212064 if(w->Dead())
20828 {
20829 13141 break;
20830 }
20831 11198923 }
20832
20833 // Item flags added in 2.55:
20834 // BRang/HShot/Arrows item_flag4 is "Pick up anything" (port of qr_BRANGPICKUP)
20835 // BRang/HShot item_flag5 is "Drags Items" (port of qr_Z3BRANG_HSHOT)
20836 // Arrows item_flag2 is "Picks up items" (inverse port of qr_Z3BRANG_HSHOT)
20837 // -Em
20838
6/6
✓ Branch 0 taken 2738060 times.
✓ Branch 1 taken 454543 times.
✓ Branch 2 taken 2693374 times.
✓ Branch 3 taken 44686 times.
✓ Branch 4 taken 44765 times.
✓ Branch 5 taken 2648609 times.
3192603 if(w->id == wBrang || w->id == wHookshot || w->id == wArrow)
20839 {
20840 543994 int32_t itype, pitem = w->parentitem;
20841
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 454543 times.
✓ Branch 2 taken 44765 times.
✓ Branch 3 taken 44686 times.
543994 switch(w->id)
20842 {
20843 454543 case wBrang: itype = itype_brang; break;
20844 44765 case wArrow: itype = itype_arrow; break;
20845 case wHookshot:
20846 44686 itype = (w->family_class == itype_switchhook ? itype_switchhook :itype_hookshot);
20847 44686 break;
20848 }
20849
2/2
✓ Branch 0 taken 538953 times.
✓ Branch 1 taken 5041 times.
543994 if(pitem < 0) pitem = current_item_id(itype);
20850
5/6
✓ Branch 0 taken 44686 times.
✓ Branch 1 taken 499308 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 44586 times.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
543994 if(w->id == wHookshot && w->family_class == itype_switchhook && (itemsbuf[pitem].flags & item_flag9))
20851 { //Swap with item
20852 for(int32_t j=0; j<items.Count(); j++)
20853 {
20854 if(items.spr(j)->hit(w))
20855 {
20856 item *theItem = ((item*)items.spr(j));
20857 bool priced = theItem->PriceIndex >-1;
20858 bool isKey = itemsbuf[theItem->id].type==itype_key||itemsbuf[theItem->id].type==itype_lkey;
20859 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= game->get_item_spawn_flicker())
20860 || (((itemsbuf[w->parentitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[w->parentitem].flags & item_flag7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
20861 {
20862 if(!Hero.switchhookclk)
20863 {
20864 hooked_comborpos = rpos_t::None;
20865 hooked_layerbits = 0;
20866 switching_object = theItem;
20867 theItem->switch_hooked = true;
20868 w->misc = 2;
20869 w->step = 0;
20870 theItem->clk2 = game->get_item_timeout_dur() / 2;
20871 Hero.doSwitchHook(game->get_switchhookstyle());
20872 if(QMisc.miscsfx[sfxSWITCHED])
20873 sfx(QMisc.miscsfx[sfxSWITCHED],pan(w->x));
20874 }
20875 }
20876 }
20877 }
20878 }
20879
6/6
✓ Branch 0 taken 44765 times.
✓ Branch 1 taken 499229 times.
✓ Branch 2 taken 374939 times.
✓ Branch 3 taken 330174 times.
✓ Branch 4 taken 499229 times.
✓ Branch 5 taken 330174 times.
543994 else if((w->id==wArrow&&itemsbuf[pitem].flags & item_flag2)||(w->id!=wArrow&&!(itemsbuf[pitem].flags & item_flag5)))//An arrow with "Picks up items" or a BRang/HShot without "Drags items"
20880 {
20881
2/2
✓ Branch 0 taken 88886 times.
✓ Branch 1 taken 374939 times.
463825 for(int32_t j=0; j<items.Count(); j++)
20882 {
20883
2/2
✓ Branch 0 taken 83988 times.
✓ Branch 1 taken 4898 times.
88886 if(items.spr(j)->hit(w))
20884 {
20885 4898 item *theItem = ((item*)items.spr(j));
20886 4898 bool priced = theItem->PriceIndex >-1;
20887
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 4766 times.
4898 bool isKey = itemsbuf[theItem->id].type==itype_key||itemsbuf[theItem->id].type==itype_lkey;
20888
5/8
✓ Branch 0 taken 4898 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4898 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3789 times.
✓ Branch 5 taken 1109 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2065 times.
6963 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= game->get_item_spawn_flicker())
20889
4/6
✓ Branch 0 taken 3174 times.
✓ Branch 1 taken 2065 times.
✓ Branch 2 taken 3174 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3174 times.
4898 || (((itemsbuf[pitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & item_flag7)&&isKey))&& !priced)))
20890 {
20891
1/2
✓ Branch 0 taken 1724 times.
✗ Branch 1 not taken.
5854 if(itemsbuf[theItem->id].collect_script)
20892 {
20893 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[theItem->id].collect_script, theItem->id & 0xFFF);
20894 }
20895
20896 1724 Hero.checkitems(j);
20897 1724 }
20898 4898 }
20899 88886 }
20900 374939 }
20901
2/2
✓ Branch 0 taken 15674 times.
✓ Branch 1 taken 153381 times.
829403 else if(w->id!=wArrow) //A BRang/HShot with "Drags Items"
20902 {
20903
2/2
✓ Branch 0 taken 36900 times.
✓ Branch 1 taken 153381 times.
190281 for(int32_t j=0; j<items.Count(); j++)
20904 {
20905
2/2
✓ Branch 0 taken 28212 times.
✓ Branch 1 taken 8688 times.
36900 if(items.spr(j)->hit(w))
20906 {
20907 8688 item *theItem = ((item*)items.spr(j));
20908 8688 bool priced = theItem->PriceIndex >-1;
20909
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 8681 times.
8688 bool isKey = itemsbuf[theItem->id].type==itype_key||itemsbuf[theItem->id].type==itype_lkey;
20910
4/6
✓ Branch 0 taken 8688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8688 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8454 times.
✓ Branch 5 taken 234 times.
8688 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= game->get_item_spawn_flicker())
20911
5/10
✓ Branch 0 taken 7273 times.
✓ Branch 1 taken 1181 times.
✓ Branch 2 taken 1415 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1415 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1415 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
8688 || (((itemsbuf[pitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & item_flag7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
20912 {
20913 7273 int32_t pickup = theItem->pickup;
20914 7273 int32_t id2 = theItem->id;
20915 7273 int32_t pstr = theItem->pstring;
20916 7273 int32_t pstr_flags = theItem->pickup_string_flags;
20917
20918 7273 std::vector<int32_t> &ev = FFCore.eventData;
20919 7273 ev.clear();
20920 7273 ev.push_back(id2*10000);
20921 7273 ev.push_back(pickup*10000);
20922 7273 ev.push_back(pstr*10000);
20923 7273 ev.push_back(pstr_flags*10000);
20924 7273 ev.push_back(0);
20925 7273 ev.push_back(theItem->getUID());
20926 7273 ev.push_back(GENEVT_ICTYPE_RANGED_DRAG*10000);
20927 7273 ev.push_back(w->getUID());
20928
20929 7273 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
20930 7273 bool nullify = ev[4] != 0;
20931
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7273 times.
7273 if(nullify) continue;
20932
2/2
✓ Branch 0 taken 1076 times.
✓ Branch 1 taken 6197 times.
7273 if(w->id == wBrang)
20933 {
20934 6197 w->onhit(false);
20935 6197 }
20936
20937
2/2
✓ Branch 0 taken 6775 times.
✓ Branch 1 taken 498 times.
7273 if(w->dragging==-1)
20938 {
20939 498 w->dead=1;
20940 498 theItem->clk2 = game->get_item_timeout_dur() / 2;
20941 498 w->dragging=j;
20942 498 theItem->is_dragged = true;
20943 498 }
20944 7273 }
20945 8688 }
20946 36900 }
20947 153381 }
20948 543994 }
20949 3192603 }
20950 4883715 }
20951 14304194 void check_collisions()
20952 {
20953
2/2
✓ Branch 0 taken 4883680 times.
✓ Branch 1 taken 14304194 times.
19187874 for(uint q = 0; q < Lwpns.Count(); ++q)
20954 4883680 check_enemy_lweapon_collision((weapon*)Lwpns.spr(q));
20955 14304194 }
20956
20957 14306378 void dragging_item()
20958 {
20959
2/2
✓ Branch 0 taken 5000289 times.
✓ Branch 1 taken 14306378 times.
19306667 for(int32_t i=0; i<Lwpns.Count(); i++)
20960 {
20961 5000289 weapon *w = (weapon*)Lwpns.spr(i);
20962
20963
4/4
✓ Branch 0 taken 4537151 times.
✓ Branch 1 taken 463138 times.
✓ Branch 2 taken 4844927 times.
✓ Branch 3 taken 155362 times.
5000289 if((w->id == wBrang || w->id==wHookshot)&&itemsbuf[w->parentitem].flags & item_flag5)//item_flag5 is a port for qr_Z3BRANG_HSHOT
20964 {
20965
3/4
✓ Branch 0 taken 7247 times.
✓ Branch 1 taken 148115 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7247 times.
155362 if(w->dragging>=0 && w->dragging<items.Count())
20966 {
20967 7247 item* dragItem = (item*)items.spr(w->dragging);
20968 7247 dragItem->x=w->x;
20969 7247 dragItem->y=w->y;
20970
20971 // Drag the Fairy enemy as well as the Fairy item
20972 7247 int32_t id = dragItem->id;
20973
20974
4/4
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 6828 times.
✓ Branch 2 taken 404 times.
✓ Branch 3 taken 15 times.
7247 if(itemsbuf[id].type ==itype_fairy && itemsbuf[id].misc3)
20975 {
20976 404 movefairynew2(w->x,w->y,*dragItem);
20977 404 }
20978 7247 }
20979 155362 }
20980 5000289 }
20981 14306378 }
20982
20983 57 int32_t more_carried_items(int screen)
20984 {
20985 57 int32_t hasmorecarries = 0;
20986
20987
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 57 times.
121 for(int32_t i=0; i<items.Count(); i++)
20988 {
20989 64 auto spr = (item*)items.spr(i);
20990
4/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 57 times.
64 if (spr->screen_spawned == screen && (spr->pickup & ipENEMY))
20991 {
20992 57 hasmorecarries++;
20993 57 }
20994 64 }
20995
20996 57 return hasmorecarries;
20997 }
20998
20999 36535 static int count_guys_from_screen(int screen)
21000 {
21001 36535 int count = 0;
21002
2/2
✓ Branch 0 taken 237871 times.
✓ Branch 1 taken 36535 times.
274406 for (int i=0; i < guys.Count(); i++)
21003 {
21004
2/2
✓ Branch 0 taken 36538 times.
✓ Branch 1 taken 201333 times.
237871 if (((enemy*)guys.spr(i))->screen_spawned == screen)
21005 201333 count += 1;
21006 237871 }
21007 36535 return count;
21008 }
21009
21010 // messy code to do the enemy-carrying-the-item thing
21011 14694306 static void roaming_item(mapscr* scr)
21012 {
21013 14694306 int screen = scr->screen;
21014 14694306 auto& state = get_screen_state(screen);
21015
4/4
✓ Branch 0 taken 14657833 times.
✓ Branch 1 taken 36473 times.
✓ Branch 2 taken 14657771 times.
✓ Branch 3 taken 36535 times.
14694306 if (!(state.item_state == ScreenItemState::CarriedByEnemy || state.item_state == ScreenItemState::MustGiveToEnemy) || !state.loaded_enemies)
21016 14657771 return;
21017
21018 // All enemies already dead upon entering a room?
21019
1/2
✓ Branch 0 taken 36535 times.
✗ Branch 1 not taken.
36535 if (count_guys_from_screen(screen) == 0)
21020 {
21021 return;
21022 }
21023
21024 36535 int guycarryingitem = -1;
21025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84544 times.
84544 for(int32_t j=0; j<guys.Count(); j++)
21026 {
21027 84544 enemy* e = (enemy*)guys.spr(j);
21028
4/4
✓ Branch 0 taken 62850 times.
✓ Branch 1 taken 21694 times.
✓ Branch 2 taken 26315 times.
✓ Branch 3 taken 36535 times.
84544 if (e->screen_spawned == screen && e->itemguy)
21029 {
21030 36535 guycarryingitem=j;
21031 36535 break;
21032 }
21033 48009 }
21034
21035
2/2
✓ Branch 0 taken 36458 times.
✓ Branch 1 taken 77 times.
36535 if (state.item_state == ScreenItemState::MustGiveToEnemy)
21036 {
21037
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(guycarryingitem == -1) //This happens when "default enemies" such as
21038 {
21039 return; //eSHOOTFBALL are alive but enemies from the list
21040 } //are not. Defer to HeroClass::checkspecial().
21041
21042 77 int32_t Item=scr->item;
21043
21044 77 state.item_state = ScreenItemState::None;
21045
21046
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 77 times.
77 if((!getmapflag(screen, mITEM) || (scr->flags9&fITEMRETURN)) && (scr->hasitem != 0))
21047 {
21048 154 auto [x, y] = translate_screen_coordinates_to_world(screen);
21049 218 additem(x,y,Item,ipENEMY+ipONETIME+ipBIGRANGE
21050
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 13 times.
77 + (((scr->flags3&fHOLDITEM) || (itemsbuf[Item].type==itype_triforcepiece)) ? ipHOLDUP : 0)
21051 );
21052 77 ((item*)items.spr(items.Count() - 1))->screen_spawned = screen;
21053 77 state.item_state = ScreenItemState::CarriedByEnemy;
21054 77 }
21055 else
21056 {
21057 return;
21058 }
21059 77 }
21060
21061
2/2
✓ Branch 0 taken 46044 times.
✓ Branch 1 taken 36535 times.
82579 for(int32_t i=0; i<items.Count(); i++)
21062 {
21063
4/4
✓ Branch 0 taken 42433 times.
✓ Branch 1 taken 3611 times.
✓ Branch 2 taken 5898 times.
✓ Branch 3 taken 36535 times.
46044 if(((item*)items.spr(i))->pickup&ipENEMY && ((item*)items.spr(i))->screen_spawned == screen)
21064 {
21065
2/2
✓ Branch 0 taken 22240 times.
✓ Branch 1 taken 14295 times.
36535 if(get_qr(qr_HIDECARRIEDITEMS))
21066 {
21067 22240 items.spr(i)->x = -128; // Awfully inelegant, innit?
21068 22240 items.spr(i)->y = -128;
21069 22240 }
21070
2/4
✓ Branch 0 taken 14295 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14295 times.
14295 else if(guycarryingitem>=0 && guycarryingitem<guys.Count())
21071 {
21072
1/2
✓ Branch 0 taken 14295 times.
✗ Branch 1 not taken.
14295 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
21073 {
21074 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
21075 {
21076 items.spr(i)->x = guys.spr(guycarryingitem)->x+guys.spr(guycarryingitem)->hxofs+(guys.spr(guycarryingitem)->hit_width/2)-8;
21077 items.spr(i)->y = guys.spr(guycarryingitem)->y+guys.spr(guycarryingitem)->hyofs+(guys.spr(guycarryingitem)->hit_height/2)-10;
21078 }
21079 else
21080 {
21081 if(guys.spr(guycarryingitem)->extend >= 3)
21082 {
21083 items.spr(i)->x = guys.spr(guycarryingitem)->x+(guys.spr(guycarryingitem)->txsz-1)*8;
21084 items.spr(i)->y = guys.spr(guycarryingitem)->y-2+(guys.spr(guycarryingitem)->tysz-1)*8;
21085 }
21086 else
21087 {
21088 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21089 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21090 }
21091 }
21092 items.spr(i)->z = guys.spr(guycarryingitem)->z;
21093 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21094 }
21095 else
21096 {
21097 14295 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21098 14295 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21099 14295 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21100 }
21101 14295 }
21102 36535 }
21103 46044 }
21104 14694306 }
21105
21106 14306378 void roaming_item()
21107 {
21108 29000684 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
21109 14694306 roaming_item(scr);
21110 14694306 });
21111 14306378 }
21112
21113 bool enemy::IsBigAnim()
21114 {
21115 return (anim == a2FRMB || anim == a4FRM8EYEB || anim == a4FRM4EYEB
21116 || anim == a4FRM8DIRFB || anim == a4FRM4DIRB || anim == a4FRM4DIRFB
21117 || anim == a4FRM8DIRB);
21118 }
21119 2418852 int32_t enemy::getFlashingCSet()
21120 {
21121 //Special cset for the dying sprite
21122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2418852 times.
2418852 if(dying)
21123 {
21124 if (!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading == fade_blue_poof)
21125 return wpnsbuf[spr_death].csets & 15;
21126 else
21127 return (((clk2 + 5) >> 1) & 3) + 6;
21128 }
21129
21130 //Normal cset
21131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2418852 times.
2418852 if (hclk <= 0)
21132 {
21133 //Special cset for the flashing animation
21134 if (flags & guy_flashing)
21135 return (frame & 3) + 6;
21136 return cs;
21137 }
21138
21139 //Hurt animations
21140
2/2
✓ Branch 0 taken 3888 times.
✓ Branch 1 taken 2414964 times.
2418852 if(type==eeGANON)
21141 3888 return (((hclk-1)>>1)&3)+6;
21142
4/4
✓ Branch 0 taken 2245020 times.
✓ Branch 1 taken 169944 times.
✓ Branch 2 taken 487138 times.
✓ Branch 3 taken 1757882 times.
2414964 else if(hclk<33 && !get_qr(qr_ENEMIESFLICKER))
21143 1757882 return (((hclk-1)>>1)&3)+6;
21144
21145 657082 return cs;
21146 2418852 }
21147
21148 81975581 bool enemy::is_hitflickerframe(bool olddrawing)
21149 {
21150
6/6
✓ Branch 0 taken 81947077 times.
✓ Branch 1 taken 28504 times.
✓ Branch 2 taken 3972522 times.
✓ Branch 3 taken 77974555 times.
✓ Branch 4 taken 3199831 times.
✓ Branch 5 taken 772691 times.
81975581 if (type == eeGANON || !hclk || !get_qr(qr_ENEMIESFLICKER))
21151 81202890 return false;
21152
21153
3/4
✓ Branch 0 taken 496051 times.
✓ Branch 1 taken 276640 times.
✓ Branch 2 taken 496051 times.
✗ Branch 3 not taken.
772691 if (!olddrawing && !getCanFlicker())
21154 return false;
21155
21156 772691 int32_t fr = game->get_spriteflickerspeed();
21157
1/2
✓ Branch 0 taken 772691 times.
✗ Branch 1 not taken.
772691 if (fr == 0)
21158 return true;
21159 772691 return frame % (fr * 2) < fr;
21160 81975581 }
21161
21162 const char *old_guy_string[OLDMAXGUYS] =
21163 {
21164 "(None)","Abei","Ama","Merchant","Moblin","Fire","Fairy","Goriya","Zelda","Abei 2","Empty","","","","","","","","","",
21165 // 020
21166 "Octorok (L1, Slow)","Octorok (L2, Slow)","Octorok (L1, Fast)","Octorok (L2, Fast)","Tektite (L1)",
21167 // 025
21168 "Tektite (L2)","Leever (L1)","Leever (L2)","Moblin (L1)","Moblin (L2)",
21169 // 030
21170 "Lynel (L1)","Lynel (L2)","Peahat (L1)","Zora","Rock",
21171 // 035
21172 "Ghini (L1, Normal)","Ghini (L1, Phantom)","Armos","Keese (CSet 7)","Keese (CSet 8)",
21173 // 040
21174 "Keese (CSet 9)","Stalfos (L1)","Gel (L1, Normal)","Zol (L1, Normal)","Rope (L1)",
21175 // 045
21176 "Goriya (L1)","Goriya (L2)","Trap (4-Way)","Wall Master","Darknut (L1)",
21177 // 050
21178 "Darknut (L2)","Bubble (Sword, Temporary Disabling)","Vire (Normal)","Like Like","Gibdo",
21179 // 055
21180 "Pols Voice (Arrow)","Wizzrobe (Teleporting)","Wizzrobe (Floating)","Aquamentus (Facing Left)","Moldorm",
21181 // 060
21182 "Dodongo","Manhandla (L1)","Gleeok (1 Head)","Gleeok (2 Heads)","Gleeok (3 Heads)",
21183 // 065
21184 "Gleeok (4 Heads)","Digdogger (1 Kid)","Digdogger (3 Kids)","Digdogger Kid (1)","Digdogger Kid (2)",
21185 // 070
21186 "Digdogger Kid (3)","Digdogger Kid (4)","Gohma (L1)","Gohma (L2)","Lanmola (L1)",
21187 // 075
21188 "Lanmola (L2)","Patra (L1, Big Circle)","Patra (L1, Oval)","Ganon","Stalfos (L2)",
21189 // 080
21190 "Rope (L2)","Bubble (Sword, Permanent Disabling)","Bubble (Sword, Re-enabling)","Shooter (Fireball)","Item Fairy ",
21191 // 085
21192 "Fire","Octorok (Magic)", "Darknut (Death Knight)", "Gel (L1, Tribble)", "Zol (L1, Tribble)",
21193 // 090
21194 "Keese (Tribble)", "Vire (Tribble)", "Darknut (Splitting)", "Aquamentus (Facing Right)", "Manhandla (L2)",
21195 // 095
21196 "Trap (Horizontal, Line of Sight)", "Trap (Vertical, Line of Sight)", "Trap (Horizontal, Constant)", "Trap (Vertical, Constant)", "Wizzrobe (Fire)",
21197 // 100
21198 "Wizzrobe (Wind)", "Ceiling Master ", "Floor Master ", "Patra (BS Zelda)", "Patra (L2)",
21199 // 105
21200 "Patra (L3)", "Bat", "Wizzrobe (Bat)", "Wizzrobe (Bat 2) ", "Gleeok (Fire, 1 Head)",
21201 // 110
21202 "Gleeok (Fire, 2 Heads)", "Gleeok (Fire, 3 Heads)","Gleeok (Fire, 4 Heads)", "Wizzrobe (Mirror)", "Dodongo (BS Zelda)",
21203 // 115
21204 "Dodongo (Fire) ","Trigger", "Bubble (Item, Temporary Disabling)", "Bubble (Item, Permanent Disabling)", "Bubble (Item, Re-enabling)",
21205 // 120
21206 "Stalfos (L3)", "Gohma (L3)", "Gohma (L4)", "NPC 1 (Standing) ", "NPC 2 (Standing) ",
21207 // 125
21208 "NPC 3 (Standing) ", "NPC 4 (Standing) ", "NPC 5 (Standing) ", "NPC 6 (Standing) ", "NPC 1 (Walking) ",
21209 // 130
21210 "NPC 2 (Walking) ", "NPC 3 (Walking) ", "NPC 4 (Walking) ", "NPC 5 (Walking) ", "NPC 6 (Walking) ",
21211 // 135
21212 "Boulder", "Goriya (L3)", "Leever (L3)", "Octorok (L3, Slow)", "Octorok (L3, Fast)",
21213 // 140
21214 "Octorok (L4, Slow)", "Octorok (L4, Fast)", "Trap (8-Way) ", "Trap (Diagonal) ", "Trap (/, Constant) ",
21215 // 145
21216 "Trap (/, Line of Sight) ", "Trap (\\, Constant) ", "Trap (\\, Line of Sight) ", "Trap (CW, Constant) ", "Trap (CW, Line of Sight) ",
21217 // 150
21218 "Trap (CCW, Constant) ", "Trap (CCW, Line of Sight) ", "Wizzrobe (Summoner)", "Wizzrobe (Ice) ", "Shooter (Magic)",
21219 // 155
21220 "Shooter (Rock)", "Shooter (Spear)", "Shooter (Sword)", "Shooter (Fire)", "Shooter (Fire 2)",
21221 // 160
21222 "Bombchu", "Gel (L2, Normal)", "Zol (L2, Normal)", "Gel (L2, Tribble)", "Zol (L2, Tribble)",
21223 // 165
21224 "Tektite (L3) ", "Spinning Tile (Combo)", "Spinning Tile (Enemy Sprite)", "Lynel (L3) ", "Peahat (L2) ",
21225 // 170
21226 "Pols Voice (Magic)", "Pols Voice (Whistle)", "Darknut (Mirror) ", "Ghini (L2, Fire) ", "Ghini (L2, Magic) ",
21227 // 175
21228 "Grappler Bug (HP) ", "Grappler Bug (MP) "
21229 };
21230
21231 15687886 int32_t enemy::get_dmisc(byte index)
21232 {
21233
20/33
✓ Branch 0 taken 14611 times.
✓ Branch 1 taken 15885 times.
✓ Branch 2 taken 3236 times.
✓ Branch 3 taken 7390 times.
✓ Branch 4 taken 2144 times.
✓ Branch 5 taken 1794 times.
✓ Branch 6 taken 1051 times.
✓ Branch 7 taken 250 times.
✓ Branch 8 taken 1852 times.
✓ Branch 9 taken 1822 times.
✓ Branch 10 taken 7793452 times.
✓ Branch 11 taken 7597384 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 308 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 40 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 216 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 884 times.
✓ Branch 25 taken 1120 times.
✓ Branch 26 taken 331 times.
✓ Branch 27 taken 238061 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 6055 times.
✗ Branch 32 not taken.
15687886 switch (index)
21234 {
21235 14611 case 0: return dmisc1;
21236 15885 case 1: return dmisc2;
21237 3236 case 2: return dmisc3;
21238 7390 case 3: return dmisc4;
21239 2144 case 4: return dmisc5;
21240 1794 case 5: return dmisc6;
21241 1051 case 6: return dmisc7;
21242 250 case 7: return dmisc8;
21243 1852 case 8: return dmisc9;
21244 1822 case 9: return dmisc10;
21245 7793452 case 10: return dmisc11;
21246 7597384 case 11: return dmisc12;
21247 case 12: return dmisc13;
21248 308 case 13: return dmisc14;
21249 case 14: return dmisc15;
21250 40 case 15: return dmisc16;
21251 case 16: return dmisc17;
21252 216 case 17: return dmisc18;
21253 case 18: return dmisc19;
21254 case 19: return dmisc20;
21255 case 20: return dmisc21;
21256 case 21: return dmisc22;
21257 case 22: return dmisc23;
21258 case 23: return dmisc24;
21259 884 case 24: return dmisc25;
21260 1120 case 25: return dmisc26;
21261 331 case 26: return dmisc27;
21262 238061 case 27: return dmisc28;
21263 case 28: return dmisc29;
21264 case 29: return dmisc30;
21265 case 30: return dmisc31;
21266 6055 case 31: return dmisc32;
21267 }
21268
21269 return 0;
21270 15687886 }
21271
21272 312 void enemy::set_dmisc(byte index, int32_t value)
21273 {
21274
3/33
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 4 times.
✓ Branch 27 taken 24 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 284 times.
✗ Branch 32 not taken.
312 switch (index)
21275 {
21276 case 0: dmisc1 = value; break;
21277 case 1: dmisc2 = value; break;
21278 case 2: dmisc3 = value; break;
21279 case 3: dmisc4 = value; break;
21280 case 4: dmisc5 = value; break;
21281 case 5: dmisc6 = value; break;
21282 case 6: dmisc7 = value; break;
21283 case 7: dmisc8 = value; break;
21284 case 8: dmisc9 = value; break;
21285 case 9: dmisc10 = value; break;
21286 case 10: dmisc11 = value; break;
21287 case 11: dmisc12 = value; break;
21288 case 12: dmisc13 = value; break;
21289 case 13: dmisc14 = value; break;
21290 case 14: dmisc15 = value; break;
21291 case 15: dmisc16 = value; break;
21292 case 16: dmisc17 = value; break;
21293 case 17: dmisc18 = value; break;
21294 case 18: dmisc19 = value; break;
21295 case 19: dmisc20 = value; break;
21296 case 20: dmisc21 = value; break;
21297 case 21: dmisc22 = value; break;
21298 case 22: dmisc23 = value; break;
21299 case 23: dmisc24 = value; break;
21300 case 24: dmisc25 = value; break;
21301 case 25: dmisc26 = value; break;
21302 4 case 26: dmisc27 = value; break;
21303 24 case 27: dmisc28 = value; break;
21304 case 28: dmisc28 = value; break;
21305 case 29: dmisc30 = value; break;
21306 case 30: dmisc31 = value; break;
21307 284 case 31: dmisc32 = value; break;
21308 }
21309 312 }
21310